Reputation: 5
I have a problem that one of my form feild has Roll no should be of the format YY-XXX
YY - last two digits of the current year
XXX - three digit number
how to validate this type of numbers using jquery?
Upvotes: 0
Views: 73
Reputation: 17637
Use RegExp /\d{2}-\d{3}/
, RegExp reference
console.log(/\d{2}-\d{3}/.test('12-123')) // true
console.log(/\d{2}-\d{3}/.test('ab-123')) // false
Upvotes: 1