KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I saw a potential answer here but that was for YYYY-MM-DD: JavaScript date validation I modified the code code above for MM-DD-YYYY like so but I still can't get it to work: String.prototype.isValidDate = function() { var IsoDateRe = new RegExp("^([0-9]{2})-([0-9]{2})-([0-9]{4})$"); var matches = IsoDateRe.exec(this); if (!matches) return false; var composedDate = new Date(matches[3], (matches[1] - 1), matches[2]); return ((composedDate.getMonth() == (matches[1] - 1)) && (composedDate.getDate() == matches[2]) && (composedDate.getFullYear() == matches[3])); } How can I get the above code to work for MM-DD-YYYY and better yet MM/DD/YYYY? Thanks.
Tags (comma-separated)
Save Edits
Cancel