Full version: jsB@nk » Time » Validation » Check Date script
URL: https://www.javascriptbank.com/check-date-script.html
You can use this JavaScript to check validation of a date.
Full version: jsB@nk » Time » Validation » Check Date script
URL: https://www.javascriptbank.com/check-date-script.html
<SCRIPT>dtFormat = 'MM/DD/YYYY'function chkDt(){udt = document.frm.mdt.value;if(udt.indexOf("/") == -1){alert('Not a valid date, format '+dtFormat);document.frm.mdt.focus();return false;}dt1 = udt.split("/")mm1 = parseInt(dt1[0]);dd1 = parseInt(dt1[1]);yy1 = parseInt(dt1[2]);if(isNaN(dd1) || isNaN(mm1) || isNaN(yy1)){alert('Invalid Date !');return false;}dt2 = new Date(mm1+'/'+dd1+'/'+yy1)dd2 = dt2.getDate();mm2 = dt2.getMonth()+1;yy2 = dt2.getFullYear();//alert(dd1+'/'+mm1+'/'+yy1);//alert(dd2+'/'+mm2+'/'+yy2);if(dd1==dd2 && mm1==mm2 && yy1==yy2)alert('Valid Date !');elsealert('Invalid Date !');document.frm.mdt.focus();}</SCRIPT><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<FORM name=frm>Enter a Date (mm/dd/yyyy) <INPUT maxLength=10 size=8 name=mdt> <BR><INPUT onclick=chkDt() type=button value="Check Date"></FORM><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->