JS verification method for Html_ login

Source: Internet
Author: User

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");}


Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.