How do I shorten the length of my field and only allow numeric characters

Cupcake
Mega Guru

I have a field on a catalog form. The field is requesting the last four digits of the SSN # or Personal ID #. Today the field is setup as a single line text field, but I want to do the following:

a) make the field size = 4

b) I only want to allow that field to have numeric characters

find_real_file.png

I want to ensure that when I shorten the field size that I am only shortening it for this variable.

Thanks,

Karen

1 ACCEPTED SOLUTION

My apologies. Try changing it to /^[0-9][0-9][0-9][0-9]$/ inside the quotes.


View solution in original post

16 REPLIES 16

That's what I was trying to do in my first response, but I lack tons of experience with regex. Thanks, Greg!


Hi Greg and Joshua,


        I am not sure what changed but this is having some issues. I went to test this field.


It allows me to enter the 4 digits, but the issue is even if it is 4 numbers it still asks me to enter a valid PIN and will not allow me to go any further.



find_real_file.png


Hi Karen,



If you could show us how your code looks like that tests this field that would help.




Cheers



Greg


Good morning Greg,


        Here is my script. I did an onChange script (see below). I deactivated it temporarily.


find_real_file.png



Thanks,


Karen


Hi Karen,



Remove forward slashes from RegExp.



Do this:


var check = new RegExp("^[0-9][0-9][0-9][0-9]$");



That should yield correct true/false results of your regex tests.




Cheers



Greg