This article originates from:http://blog.csdn.net/svitter
Develop a registered HTML page that collects the user's registration information. Includes: Name (cannot be empty), age (must exceed 17 years old), weight (30-150kg), Class (drop-down list), login password (at least 8 digits long), Confirm password (and login password consistent), Email (can't be empty), telephone, QQ, resume and other information. The corresponding validation is created for the elements of these tables, and if an error is detected, an error is displayed with a red word after the input box. The single-line text input box you learned in the previous sections text, drop-down list box Select, Password input box password, multiline text input box textarea. This is a more practical user registration form.
Register.html:
<!doctype html>
CHECK.CSS:Td.check{color: #C00; font-weight:bold;}
Load.js:function Check (str) {var x = document.getElementById (str); var y = document.getElementById (str+ "Check");//alert ("check!"); if (str== "name") {if (x.value== "") Y.hidden = False;elsey.hidden = true;} else if (str== "age") {if (IsNaN (x.value) | | X.value <) Y.hidden = False;elsey.hidden = true;} else if (str== "weight") {x = X.value;if (IsNaN (x) | | x < | | x > Max) Y.hidden = False;elsey.hidden = true;} else if (str== "password") {x = x.value.length;if (x < 8) {Y.hidden = False;//alert ("check!");} Elsey.hidden = true;} else if (str== "Cpassword") {var z = document.getElementById ("password"). Value;x = x.value;if (x! = z) Y.hidden = False;elsey . Hidden = true;} else if (str== "email") {x = X.value.indexof ("@") if (x = =-1) Y.hidden = False;elsey.hidden = true;} return Y.hidden;} function validate () {var arr=["name", "Age", "weight", "password", "Cpassword", "email"];var i = 0;submitok = True;while (i <= 5) {if (!check (Arr[i])) {alert (arr[i]+ "wrong!"); Submitok = False;break;} i++;} if (submitok) {alert ("Submit successfully! "); return True;} Else{alert ("Commit failed"); return false;}} function load_greeting () {//alert ("visit \ n");}