"About JavaScript" common form user name, password cannot be empty

Source: Internet
Author: User

In the Forum and other system user registration function, if the user forgot to fill in the required information, such as user name, password, etc., the browser will pop up a warning box, prompting the user is currently not filled information.

This is a typical application that is implemented through JavaScript. is a simple user registration page:

The user must enter the user name, password, and confirmation password, and the password must be the same two times, otherwise the system will prompt an error.

When the user does not enter a user name to submit the registration, the system will pop up as shown in the warning window, forcing the user must enter the user name.

A simple approach:

1<script language= "JavaScript" >2 functionCheck () {3 if(document.form1.username.value== ""){4Alert ("User name cannot be empty!") ");5 Document.form1.username.value.focus ();6 return false;7 }8 if(document.form1.password.value== ""){9Alert ("Password cannot be empty!") ");Ten Document.form1.password.value.focus (); One return false; A } - if(document.form1.password.value.length<6) - { theAlert ("Password length cannot be less than 6 bits"); - Document.form1.password.value.focus (); -     return false; - } + Else - if(document.form1.repassword.value!=document.form1.password.value) { +Alert ("Two input passwords are inconsistent!") "); A Document.form1.repassword.focus (); at return false; - }} -</script>

"About JavaScript" common form user name, password cannot be empty

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.