Reputation: 1357
I have jQuery datepicker with dateFormat d.m.yy
which should parse dates like 1.1.1990 or 31.12.2014. The problem is that the parseDate()
function parses successfully even date 1.1.1 as 1.1.2014.
My question is - can I restrict somehow the parse to reject such dates? I want only years with four digits to be parsed.
Upvotes: 0
Views: 71
Reputation: 13222
Try checking before they submit or on change of datepicker like this:
var dateReg = /^\d{1,2}([/])\d{1,2}\1\d{4}$/;
if((!yourdate.match(/\S/)) || (!yourdate.match(dateReg)))
{
//if this is true then
window.alert("You must enter a valid date");
}
Upvotes: 1