I am trying to check that what the user inputs begins with two letters, followed by either 6, 8 or 10 numbers. Checking string length should be ok but is there a neater way to check that the first two characters are letters and that the subsequent 6, 8 or 10 characters are numbers than converting each character to unicode and then checking that way?
Share
You can use regex:
This will pass only if the first 2 are alphas and next 6 or 8 or 10 are numbers.
JS:
Here’s complete JS example: http://jsfiddle.net/mrchief/sRLrW/