I am trying to validate a text field so that they must enter a seven character value. The first character must be alphanumeric and the next six must be numeric. I have no problem with validating the length, but not sure how to achieve the rest. Any help would be appreciated.
Share
var regex = new RegExp(‘/^[a-zA-z]{1}[0-9]{6}$/’) ;
Did you want to allow any spaces or special characters?
Whoops need to add in what Ivan said as I didnt realize you were unfamiliar with regular expressions.
Use
var regex = new RegExp(‘/^[a-zA-Z0-9]{1}[0-9]{6}$/’) ;
if(myString.match(regex)){
“YOUR CODE” ;
}
Thanks Ivan missed that alpha part.