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