FunctionvalidateNum (val) {// verify the integer varpatten/^ -? \ D + $/; returnpatten. test (val);} functionvalidateRealNum (val) {// verify the real number varpatten/^ -? \ D + \.? \ D * $/; returnpatten. test (val);} fu
Function validateNum (val) {// verify the integer
Var patten =/^ -? \ D + $ /;
Return patten. test (val );
}
Function validateRealNum (val) {// verify the real number
Var patten =/^ -? \ D + \.? \ D * $ /;
Return patten. test (val );
}
Function validateNum (val) {// verify the decimal point, retain one decimal point
Var patten =/^ -? \ D + \.? \ D {0, 1} $ /;
Return patten. test (val );
}
Function validateFloat (val) {// verify Decimals
Var patten =/^ -? (? : \ D + | \ d {1, 3 }(? :, \ D {3}) + )(? : \. \ D + )? $ /;
Return patten. test (val );
}
Function validateNumOrLetter (val) {// only numbers and letters can be entered
Var patten =/^ [A-Za-z0-9] + $ /;
Return patten. test (val );
}
Function validateColor (val) {// verify the color
Var patten =/^ # [0-9a-fA-F] {6} $ /;
Return patten. test (val );
}
Function validateUrl (val) {// verify the URL
Var patten =/^ (https? | Ftp): \ // ([a-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | (% [\ da-f] {2}) | [! \ $ & '\ (\) \ * \ +,; =] | :)*@)? (\ D | [1-9] \ d | 1 \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d | [1-9] \ d | 1 \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d | [1-9] \ d | 1 \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d | [1-9] \ d | 1 \ d | 2 [0-4] \ d | 25 [0-5]) | ([a-z] | \ d | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | ([a-z] | \ d | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) ([a-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) * ([a-z] | \ d | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) \.) + ([a-z] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | ([a-z] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) ([a-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) * ([a-z] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) \.?) (: \ D *)?) (\/([A-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | (% [\ da-f] {2}) | [! \ $ & '\ (\) \ * \ +,; =] |: | @) + (\/([A-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | (% [\ da-f] {2}) | [! \ $ & '\ (\) \ * \ +,; =] |: | @)*)*)?)? (\? ([A-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | (% [\ da-f] {2}) | [! \ $ & '\ (\) \ * \ +,; =] |: | @) | [\ UE000-\ uF8FF] | \/| \?) *)? (# ([A-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | (% [\ da-f] {2}) | [! \ $ & '\ (\) \ * \ +,; =] |: | @) | \/| \?) *)? $/I;
Return patten. test (val );
}
Function validateNull (val) {// verification is empty
Return val. replace (/\ s +/g, ""). length = 0;
}
Function validateDate (val) {// verification time 2010-10-10
Var patten =/^ \ d {4} [\/-] \ d {1, 2} [\/-] \ d {1, 2} $ /;
Return patten. test (val );
}
Function validateNumLetterLine (val) {// only numbers, letters, and underscores can be entered
Var patten =/^ [a-zA-Z0-9 _] {1,} $ /;
Return patten. test (val );
}
Author: uohzoaix