Hi folks-
I need to know if it’s possible to use javascript variables within a regular expression…..how would this work? If I had the following:
[CODE]//Validate DL for 11 digits or SSN or 8 digits
//South Dakota
function validate_dl_34(str_dlstate)
{
var ssn = new String(“getField( “SSN” )”)
var re = /^d{11}$|^d{8}$/;
return re.test(str_dlstate);
}
This will validate for 11 digits or 8 digits……as you see I have the SSN pulling from a database and stored in a new variable. At that point, how could I include that variable within the regular expression?
Driving me nuts, don’t see any references online about this……thanks!! ?
T