This should be easy. I have the following code:
var patt = new RegExp("\d{3}[\-]\d{1}");
var res = patt.test(myelink_account_val);
if(!res){
alert("Inputs must begin with something like XXX-X of numbers and a dash!");
return;
}
Basically, forcing users to enter something like 101-4 . The code is borrowed from Social Security Number input validation . And I can confirm that my inputs are indeed like 101-4; only the first five characters need to fit the pattern.
But running my code always gives the alert--the condition is never matched.
Must be something simple?!
Thanks.