var rex 1-9 12 01 1-9 0-2 20 19 console log rex test 25-02-2012 consol

1
2
3
4
5
var rex = /^(0?[1-9]|[12]]\d|3[01])-(0?[1-9]|1[0-2])-(20|19)\d{2}?/;
console.log(rex.test('25-02-2012'));
console.log(rex.test('25-2-2012'));
console.log(rex.test('01-12-2011'));
console.log(rex.test('2-12-1978'));