Remove Spaces from Text Input

More
1 month 4 hours ago #171306 by teracomp
teracomp created the topic: Remove Spaces from Text Input
I have a Multiple Short Text question that includes 4 subquestions: First name, Last name, Email, and Code.

Spaces are invalid characters for email and code.

What is the best method for either disallowing spaces or removing them programmatically?

Dave Phillips
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 4 hours ago #171309 by teracomp
teracomp replied the topic: Remove Spaces from Text Input
I've also run into other invalid characters being entered in the email field. So the question should be broadened to "Remove Unwanted characters from Text Input"

Dave Phillips

Please Log in or Create an account to join the conversation.

More
1 month 3 hours ago #171311 by Joffm
Joffm replied the topic: Remove Spaces from Text Input
Hi, teracomp,

I just tried to remove spaces programmatically.
Just by an equation like {str_replace(" ","",M1_SQ001)}. Removes one or more spaces.

Now I saw your addition.

Well here I should say, use regular expressions.

Best regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in or Create an account to join the conversation.

More
1 month 3 hours ago #171313 by teracomp
teracomp replied the topic: Remove Spaces from Text Input
Seems that spaces are 99% of my problem, so might be all I need.
Where do I add the equation? I've tried: {str_replace(" ","",userdata_email)} in the question "sub-question validation expression" but that does not appear to fire...at least not in the Preview Question interface.

Dave Phillips

Please Log in or Create an account to join the conversation.

More
1 month 3 hours ago #171319 by tpartner
tpartner replied the topic: Remove Spaces from Text Input
If you break the question into separate short-text questions, you could use the strpos() function something like this in the question validation equation to disallow spaces.

!is_numeric(strpos(Q2, ' '))

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: teracomp

Please Log in or Create an account to join the conversation.

More
1 month 2 hours ago #171321 by Joffm
Joffm replied the topic: Remove Spaces from Text Input
i set the question with the equation right after the multi text question.
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: teracomp

Please Log in or Create an account to join the conversation.

More
1 month 44 minutes ago #171335 by DenisChenu
DenisChenu replied the topic: Remove Spaces from Text Input

teracomp wrote: Seems that spaces are 99% of my problem, so might be all I need.
Where do I add the equation? I've tried: {str_replace(" ","",userdata_email)} in the question "sub-question validation expression" but that does not appear to fire...at least not in the Preview Question interface.

To use subquestion validation, you need something like this

str_replace(" ","",userdata_email) == userdata_email

tpartner and Joffm propose you to fix the value when user click next.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: teracomp

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!