arnavi
arnavi

Reputation: 5

how to validate a number contains current year

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

Answers (1)

Steely Wing
Steely Wing

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

Related Questions