I am trying to extend the jQuery UI Datepicker for adding some validations.
I searched a lot in the internet, but I could not get any help. I found SO q
Try this,
JsFiddle
$(function() {
$( "#datepicker" ).datepicker({ dateFormat: "yy-M-dd" });
$('#datepicker').on("keyup", function(e) {
var val = this.value;
if(!ValidateDate(val)){
console.log("Date must be 2014-Mar-01 Format")
}
});
});
function ValidateDate(dtValue)
{
console.log(dtValue)
var patt = new RegExp(/^20\d\d-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(0[1-9]|[12][0-9]|3[01])$/);
var res = patt.test(dtValue);
return res;
}