date validation through jquery......................
$("#Text3").datepicker({numberOfMonths:2,
showButtonPanel: true,
dateFormat:'dd/mm/yy',
autoSize: true,
maxDate: '+3m',
Image:"image.axd.jpeg",
showOn: 'both'
});
$("#button").click(function(){
//alert("hello");
var dateformat= document.getElementById("Text3");
var splitvaue= dateformat.value.split('/');
var date= new Date();
alert(date.getMonth()+1);
// if((parseInt(splitvaue[0])>=date.getDate())&&(parseInt(splitvaue[1]))>=(date.getMonth()+1)){
if(parseInt(splitvaue[1])<13 && parseInt(splitvaue[0])<=31){
if(parseInt(splitvaue[2])==(date.getFullYear())) {
alert("hello");
}
}
else
{
alert("should be enter Today Date");
}
});
});
It accepts 24/13/2012 as date and says "You are right". But that is wrong.
ReplyDeletefound this post which validates the date.
http://jquerybyexample.blogspot.com/2011/12/validate-date-using-jquery.html
update the error correction thanks for suggerstions.
ReplyDelete