How to make others field text only ?

More
5 years 5 months ago #79679 by JackChow
JackChow created the topic: How to make others field text only ?
Hi,

I recently started using limesurvey and trying to set up a survey online. I have two questions in particular

1) How can I make others field to allow text only ? I see we have option for numbers only.

2) I would like to change the admin login url. Eg: limesurvey.com/admin to limesurvey.com/backend

Please Log in to join the conversation.

More
5 years 5 months ago #79684 by DenisChenu
DenisChenu replied the topic: How to make others field text only ?
Hello,

For 2:
Maybe you can see in config-default.php:
$homeurl                 = "$rooturl/admin";         // The website location (url) of the admin scripts
$homedir                 = "$rootdir".DIRECTORY_SEPARATOR."admin";       // The directory path of the admin scripts

For 1: i don't understand exactly what you want, you want only a to z and A to Z caracter ?

Try
regexMatch('[a-zA-Z]',this)
or something like that in Sub-question validation equation

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: JackChow

Please Log in to join the conversation.

More
5 years 5 months ago #79692 by JackChow
JackChow replied the topic: How to make others field text only ?
Thanks for your reply.

I want to allow only text(a-z or A-Z) in the others field of list with radio buttons.

I have option for only allow numbers in advanced options. Where should I put that regex exp ? I don't see any validation field.

Please Log in to join the conversation.

More
5 years 5 months ago #79696 by tpartner
tpartner replied the topic: How to make others field text only ?
I don't think there is a validation field for "Other" but you could put a mask onthe input field. Something like this workaround - docs.limesurvey.org/Workarounds%3A+Manip...vey#Text_input_masks

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: JackChow

Please Log in to join the conversation.

More
5 years 5 months ago #79699 by DenisChenu
DenisChenu replied the topic: How to make others field text only ?
Hello,

Maybe some script like that:
$('question'+QQ' input.text').bind('keypress', function (event) {
    var regex = new RegExp("^[a-zA-Z]+$");
    var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
    if (!regex.test(key)) {
       event.preventDefault();
       return false;
    }
});
Or you can use some jquery plugin , this one bassistance.de/jquery-plugins/jquery-plugin-validation/ for example.

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 .

Please Log in to join the conversation.

More
5 years 5 months ago #79712 by JackChow
JackChow replied the topic: How to make others field text only ?
Sorry for being noob. May I ask where should I include this script ?

Please Log in to join the conversation.

More
5 years 5 months ago #79713 by DenisChenu
DenisChenu replied the topic: How to make others field text only ?
Hello,

Look at :
How to use Script (eg.JavaScript etc.) in LimeSurvey?

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: JackChow

Please Log in to join the conversation.

More
5 years 5 months ago #79801 by JackChow
JackChow replied the topic: How to make others field text only ?
Hi,

Thanks for the links they are very useful. I have choose to implement the digitalbush plugin. Followed all instructions. But it is not working. Please find more information

<script type="text/javascript" charset="utf-8">
$(document).ready(function($) {
$("#answer55937X1X3").mask("999-99-9999",{ placeholder:"#" });
});
</script>

The survey logic is

Logic File for Survey # 55937

This question, by itself, does not contain any syntax errors

# Name [ID] Relevance [Validation] (Default) Text [Help] (Tip)
G-1 SECTION 1: BASIC PERSONAL AND HOUSEHOLD INFORMATION
[GID 1] 1
Q-5 *Q1_3
[QID 3]
List (radio) [L] 1
(VALIDATION: ((Q1_3.NAOK != '-oth-' || (Q1_3.NAOK == '-oth-' && strlen(trim(Q1_3_other.NAOK)) > 1))))
1.3 Level of Education



[HELP: ]
(TIP:
Please also fill in the "other comment" field.
)
Question Attribute Value
display_columns 1
other_comment_mandatory 1
SQ-1 Q1_3_other Other
A[0]-1 A1 [VALUE: A1] Elementary
A[0]-2 A2 [VALUE: A2] Primary
A[0]-3 A3 [VALUE: A3] Secondary
A[0]-4 A4 [VALUE: A4] Tertiary
A[0]-5 A5 [VALUE: A5] No Formal Education


I check the js file it is loading during the survey. I'm using 1.92 version of limesurvey. Any help is much appreciated.

Please Log in to join the conversation.

More
5 years 5 months ago #79802 by tpartner
tpartner replied the topic: How to make others field text only ?
I can't speak to how well that plugin works but I believe the ID for the "Other" text input for a radio question should be something like 11111X22X33othertext.

Try changing:
$("#answer55937X1X3").mask("999-99-9999",{ placeholder:"#" });

To:
$("#answer55937X1X3othertext").mask("999-99-9999",{ placeholder:"#" });

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: JackChow

Please Log in to join the conversation.

More
5 years 5 months ago #79803 by JackChow
JackChow replied the topic: How to make others field text only ?
Thanks a lot. It is working. Now I'm trying to figure out how to put condition a-z or A-Z.

Please Log in to join the conversation.

More
5 years 5 months ago #79829 by JackChow
JackChow replied the topic: How to make others field text only ?
Hi,

I just realized masking input is not what I need. I want allow user to enter anything they want in other.

As suggested above I think I need to use
bassistance.de/jquery-plugins/jquery-plugin-validation/

But I'm trying to figure out what would be the script. Too many APIs and I'm not a programmer.

Any help ?

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now