A few days ago to see brother Liao about using JavaScript check YYYY-MM-DD format of the article, debugging a bit, found wrong, now give the correct source code, welcome to advise.
Program under the PWIN98,PWS, but there are two points do not understand, please enlighten us!
1, if using var Date1 = new Date (2000,12,31); , Date1 will get 2001,1,31.
The month automatically adds 1.
2, the format of new date (2000,12,31) is different from the new date (12,31,2000) format in the book, is it related to the date of the server?
*******************************
<script language=javascript>
<!--
function Form4_onsubmit ()
{
Ymd1=form4.date1.value.split ("-");
Month1=ymd1[1]-1
var Date1 = new Date (ymd1[0],month1,ymd1[2]);
if (Date1.getmonth () +1!=ymd1[1]| | Date1.getdate ()!=ymd1[2]| | Date1.getfullyear ()!=ymd1[0]| | YMD1[0].LENGTH!=4)
{
Alert ("Illegal date, please enter" in "YYYY-MM-DD" format);
Form4.date1.focus ();
return false;
}
Alert ("Enter Date:" + Form4.date1.value);
return true;
}
-->
</SCRIPT>
<% nowdate=year (date) & "-" &month (date) & "-" &day (date)%>
<form name=form4 method= "POST" action= "chkfind.asp" onsubmit= "return Form4_onsubmit ()" >
<input type= "text" name= "date1" size= "" Value=<%=nowdate%> >
</form>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.