Restrict text boxes to enter dates in YYYY-MM-DD format, text box yyyy-mm-dd
Text input boxes sometimes have restrictions on the input text, such as limiting the date of the input YYYY-MM-DD format, can be achieved through regular expressions
Function IsDate (str) {var reg =/^ (\ d {4})-(\ d {2})-(\ d {2}) $ /; if (str = '') {return false;} var arr1_reg.exe c (str); if (! Reg. test (str) | parseInt (RegExp. $2) >=12 | parseInt (RegExp. $3) >=31) {return false;} return true ;}
Arr=reg.exe c (str), arr is an array that places the matched text in the first element and the Child Matching Element in the following element:
For example, str = ", then the corresponding arr = [" "," 2015 "," 06 "," 05 "]
RegExp. $2 is equivalent to arr [2], that is, after arr is returned, the corresponding RegExp is also assigned a value, which is the same as the value in arr.