/**
* DHTML date validation script.
*/
// Declaring valid date character, minimum year and maximum year
VaR dtch = "-";
VaR minyear = 1900;
VaR maxyears = 2100;
Function isinteger (s ){
VaR I;
For (I = 0; I <S. length; I ++ ){
// Check that current character is number.
VaR c = S. charat (I );
If (C <"0") | (C> "9") return false;
}
// All characters are numbers.
Return true;
}
Function stripcharsinbag (S, bag ){
VaR I;
VaR returnstring = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnstring.
For (I = 0; I <S. length; I ++ ){
VaR c = S. charat (I );
If (bag. indexof (c) =-1) returnstring + = C;
}
Return returnstring;
}
Function daysinfebruary (year ){
// February has 29 days in any year evenly divisible by four,
// Snapshot t for Centurial years which are not also divisible by 400.
Return (Year % 4 = 0 )&&((! (Year % 100 = 0) | (Year % 400 = 0 )))? 29: 28 );
}
Function daysarray (n ){
For (VAR I = 1; I <= N; I ++ ){
This [I] = 31
If (I = 4 | I = 6 | I = 9 | I = 11) {This [I] = 30}
If (I = 2) {This [I] = 29}
}
Return this
}
Function isdate (dtstr ){
VaR daysinmonth = daysarray (12)
VaR pos1 = dtstr. indexof (dtch)
VaR pos2 = dtstr. indexof (dtch, pos1 + 1)
VaR stryear = dtstr. substring (0, pos1)
VaR strmonth = dtstr. substring (pos1 + 1, pos2)
VaR strday = dtstr. substring (pos2 + 1)
Stryr = stryear
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.