New Field Validation in Survey Designer

cstangoe
Mega Guru

Hi All.

Any ideas how I can create a new Field Validation with Survey Designer as I require a answer just to only accept numbers

 

Thanks

1 REPLY 1

-Andrew-
Kilo Sage

Either change the field type to integer or try this on-chance client script:

 

 var val = newValue;


               var achar = '0123456789.'; //Values you want to check for in this have only allowed number but you could to special characters or letter
               var failmsg = 'Enter Here the message you wish to display to the user.';

               //create an array that is all lowercase based on the value if you want this case sensitive remove .toLowerCase()

               var array1 = val.toLowerCase().split('');
               for (var i=0; i < array1.length; i++){
                       if (achar.indexOf(array1[i]) >= '0'){
                       }
                       else{
                               alert(failmsg);
                               g_form.setValue('replace_with_field_this_is_run_against', ''); //clear out the field if value contains a character that does not match.

                       }

               }
       }