Regular Expression - Javascript validation

Hi all

this should be easy. I'm probably missing something really basic.

Here's the deal: 16 digit number for the respondent to enter. I have set up 4 text fields allowing 4 characters each (they are text fields because at least 3 of the sets could easily have a leading zero).

Here's my pattern:


var regcheck = /^([0-9]{4})$/;


and here's how I'm calling it:


if(!regcheck.test(SSI_GetValue("Q10c_number1")))
{
strErrorMessage = "Your membership number consists of 16 digits. No letters or spaces. Please enter in the pattern provided.";
}


It ALMOST works. Doesn't allow alpha or spaces. PROBLEM - also doesn't allow leading zeros!

Have tried \d{4} as well. Can't for the life of me see what I'm doing wrong!

p.s. using version 7.

Resolved
7 replies