JavaScript Tutorial date format validation code
<form id= "myFM" name= "myFM" "method=" post "action="? >
<table class= "Table_list" >
<caption>
Increase the price
</caption>
<tr>
<TD class= "Align_c" ><span class= "Paginator" > Year-month-day </span>:<span class= "Red" >*</span> </td>
<TD >
<label>
<input name= "Dates" type= "text" size= "/>"
<span class= "STYLE1" >"2010-04-04" </span></label></td>
</tr>
<tr>
<TD class= "Align_c" ><span class= "paginator" > Average price <span class= "Red" >*</span></span> </td>
<td><label>
<input name= "Price" type= "text" size= "ten"/>
<span class= "STYLE1" >658</span></label></td>
</tr>
<tr>
<TD width= "20%" class= "Align_c" > </td>
<TD width= "80%" ><label>
<input type= "Submit" name= "Submit" onclick= "return IsDate ();" value= "Submit"/>
<input type= "reset" name= "Submit2" value= "reset"/>
</label></td>
</tr>
</table>
</form>
<script language= "JavaScript" >
function IsDate () {
var regex = new RegExp ("^ (?:(?:( [0-9] {4} (-|/) (?:(?: 0? [1,3-9]|1[0-2]) (-|/) (?: 29|30) | ((?: 0? [13578]|1[02]) (-|/) 31)) | ([0-9]{4} (-|/) (?: 0?) [1-9]|1[0-2]) (-|/) (?: 0? [1-9]|1\d|2[0-8]) | (((?:( \d\d (?: 0 [48]| [2468] [048]| [13579] [26]) | (?: 0 [48]00| [2468] [048]00| [13579] [26]00)) (-|/) 0?2 (-|/) 29))));
var dateValue = Myfm.dates.value;
var dateprice = Myfm.price.value;
if (!regex.test (DateValue))
{
Alert ("Date must be in 2010-1-11 or 2010-01-01 writing format");
Myfm.dates.value = "";
Myfm.dates.focus ();
return false;
}
else if (isNaN (Dateprice))
{
Alert ("Average price must be a number Oh");
Myfm.price.value = "";
Myfm.price.focus ();
return false;
}
}
</script>
This site original article reproduced annotated from Www.111cn.net
*/