KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've just written this regular expression in javaScript however it doesn't seem to work, here's my function: function isGoodDate(dt){ var reGoodDate = new RegExp("/^((0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2})*$/"); return reGoodDate.test(dt); } and this is how I call it in my form validation if(!isGoodDate(userInput[1].value)){ alert("date not in correct format of MM/dd/YYYY"); return false; } now I want it to return MM/DD/YYYY however if I put a valid date in it raises the alert? Any ideas anyone?
Tags (comma-separated)
Save Edits
Cancel