// Take two-digit function Todou (n) { if (N < 10< Span style= "color: #000000") { return ' 0 ' + n} else { return ' + n}} // intercept number function GETN (s) { if (s) { return s.replace (/[^0-9\.) /ig, "); }}
Remove space before and after
String.prototype.trim = function () {
Return This.replace (/(^\s*) | ( \s*$)/g, ");
}
//seeking AgefunctionGetage (strbirthday) {varReturnage; varStrbirthdayarr = Strbirthday.split ("-"); varBirthyear = strbirthdayarr[0]; varBirthmonth = strbirthdayarr[1]; varBirthDay = strbirthdayarr[2]; D=NewDate (); varNowyear =d.getfullyear (); varNowmonth = D.getmonth () + 1; varNowday =d.getdate (); if(Nowyear = =birthyear) {Returnage= 0;//the same year is 0 years old}Else { varAgediff = Nowyear-birthyear;//Years of Difference if(Agediff > 0) { if(Nowmonth = =birthmonth) { varDaydiff = Nowday-birthday;//the difference between days if(Daydiff < 0) {Returnage= AgeDiff-1; } Else{returnage=Agediff; } } Else { varMonthdiff = Nowmonth-birthmonth;//the difference of the month if(Monthdiff < 0) {Returnage= AgeDiff-1; } Else{returnage=Agediff; } } } Else{returnage=-1;//Return-1 indicates birth date input error later than today } } returnReturnage;//age of Return years}
The old driver ...
Take two digits, intercept the number, ask for age, remove the space before and after