The circulating main code is as follows:
/ **************************** Author: Zhao-year peak * format NULL is empty judgment NUM digital AB letter CHS Chinese character Bit bit phone format Email email format http format * / function check_null (check_obj) {var str = '; for (i = 0; i function check_num (check_obj) {var i, j, strTemp; // abcdefghijklmnopqrstuvwxyz strTemp = "0123456789"; if (check_obj.length == 0) return false; for (i = 0; i function check_ab (check_obj) {var i, j, strTemp; strTemp = "abcdefghijklmnopqrstuvwxyz"; if (check_obj.length == 0) return false; for (i = 0; i Function check_chs (check_obj) {if (check_obj.search (/ [^ / x00- / x80] /)> = 0) {return true;} else {returnaf false;}} function check_bit (check_obj, bit_obj) {arry_str = bit_obj.split ( '_'); var obj_length = check_obj.length; switch (arry_str [2]) {case ">": if (obj_length> arry_str [1]) {return True;} Break; Case "<": IF (obj_length Function check_email (check_obj) {if (check_obj.search (/ ^ [/ w -] @ [/ w -] /. [A-ZA-Z0-9] {2,} $ /)> = 0) { Return True;} else {return false;}} Function check_http (check_obj) {if (check_obj.search (/ ^ https?: (/ w | -) /.) / w //? $ / i)> = 0) {Return True;} else {return False;}} / ************************************************** * Function Purpose: Automatic Detection Form * Parameters: Form_Name The FORM Object Name * INPUT_ARRY To detect the first location of the INPUT control target group * Input_arry parameter array is the name of the * control, the second location is if an error * To display Error information string, third bit * set the detection range flag, if the multi-flag can * use, separate. For example, 'num, null' cannot be empty, * and can only be digital * / function auto_check_form (form_name, input_arry) {for ('ok'); alert_flag = 0; arry_str = input_arry [Num] [2] .split (','); for (var es_num in arry_str) {switch (arry_str [es_num]) {case "null": if (Check_null (INPUT_ARRY [NUM] [0] .Value) == True) {Alert_flag = 1;} Break; Case "NUM": if (Check_NUM (INPUT_ARRY [NUM] [0] .Value) == false) {alert_flag = 1;} Break case "ab": IF (Check_ab (Input_arry [NUM ] [0] .Value) == false) {alert_flag = 1;} Break; Case "CHS": IF (Check_CHS (INPUT_ARRY [NUM] [0] .Value) == false) {alert_flag = 1;} Break; Case "phone": if (Check_Phone (INPUT_ARRY [NUM] [0] .Value) == false) {alert_flag = 1;} Break; CASE "email": if (check_email (INPUT_ARRY [NUM] [0] .Value) === false) {alert_flag = 1;} Break; Case "http": if (Check_HTTP (Input_arry [Num] [0] .value) == false) {alert_flag = 1;} Break; default:} IF (arry_str [es_num] .Search (/ bit _ * /)> = 0) {if (Check_bit (INPUT_ARRY [NUM] [0] .Value, arry_str [ ES_NUM]) == false) {alert_flag = 1;}}} f (alert_flag == 1) {Alert (INPUT_ARRY [NUM] [1]); return 0;}} form_name.submit ();} Note: Checkspace function is empty The HTML square calls more judgment support through arrays and control object names, comparison mode, such as the third parameter of the second parameter in the second parameter can be written: οnclick = "auto_check_form (test1, [[text_1, ' Cannot be empty and can only be numbers', 'null, num'], [text_2, 'can't be empty can only be alphabet', 'null, ab'], [text_3, 'can not be less than 9 bits ",' Null, Num , Bit_9_> '], [Text_4,' Phone Number Enter Error ',' Null, Phone, Bit_13 _ <= '], [TEXT_5, "Please enter Chinese characters to do the name', 'Null, CHS, Bit_6_>']); ">" Null, phone, bit_13 _ <= These are all matching characters. Only an example of an example of this version has been corrected BUG is now a full version.