A recent project summary has a date control in which the use of a date control in a previous project typically has the following conditions.
(1) When you click on the text box to pop up the Calendar control's selection screen, manually select the time on the calendar control. This practice has a great advantage is not to do the date of the correctness of the check, the general situation is only to compare from and to the relationship between the date order to ensure the correctness. This project is also most commonly used.
(2) Click the calendar symbol to pop up the calendar selection screen, text box content can be entered manually. In this case, there are usually two kinds of check, one is the text box after the content input, the way to go JS, by invoking the validity of the date, the error message or continue the next operation. The other is for the input of the text box, limit the input, through the KeyUp listening input content, and then return the desired content to make some character input invalid.
(3) For the text box input problem, usually through the input method of the system to control only the English characters and the number of the system, you need to do the corresponding code in the background, because IE text box is very silly, even if you limit the input, for the universal copy and paste text box can not be refused.
The other one is not related to this check, that is, the invalid text box settings, invalid text content is not to be taken. In general, the method of hiding variables is used to solve the problem.
The code for date validation references the following code:
1 function Isvalidatedate (date) {2Date =$.trim (date);3 varReg =/^ (\d{4})-(\d{2})-(\d{2})$/;4 reg.exec (date);5 if(!reg.test (date) && regexp.$2<= A&& regexp.$3<= to) {6 return false;7 }8 varYear , month, day;9Year = parseint (Date.split ("-")[0],Ten);Tenmonth = parseint (Date.split ("-")[1],Ten); OneDay = parseint (Date.split ("-")[2],Ten); A if(! ((1<= month) && ( A>= month) && ( to>= Day) && (1<=Day))) { - return false; - } the if(Month <=7) && ((Month%2) ==0) && (Day >= to)) { - return false; - } - if(Month >=8) && ((Month%2) ==1) && (Day >= to)) { + return false; - } + if(Month = =2) { A if(Year% -==0) || (Year%4==0) && (Year% -!=0))) { at if(Day > in) { - return false; - } -}Else { - if(Day > -) { - return false; in } - } to } + return true; -}
View Code
The front desk in jquery about date correctness check