Link to home
Start Free TrialLog in
Avatar of Meinhoonaa
Meinhoonaa

asked on

need help with javascript

I need a javascript to validate a string. It should be max 7 characters long and minimum 4 characters long. The first 2 characters must be numeric. Position 3 and 4 must be alpha, and the remaining positions must be numeric.
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Test page : http://jsfiddle.net/WVx97/

function myStringIsCorrect( myString ) { // return true or false
     return /^\d\d[a-z][a-z]\d?\d?$/.test(myString)
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of QPR
QPR
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial