How to validate date user input in javascript on mm:dd:yy format

Nighthero

New Member
I tried validating date with the following code:-\[code\] function d(id){ var n= document.getElementById(id); var re=/^(?:(0[1-9]|1[012])[\- \/.](0[1-9]|[12][0-9]|3[01])[\- \/.](19|20)[0-9]{2})$/; if (re.test(n.value)) { n.style.backgroundColor="#52F40C"; } else { window.alert("Invalid date"); n.style.backgroundColor="#F40C0C"; n.focus(); n.value=""; }}\[/code\]But it isn't working. What is the problem with this code?
 
Back
Top