Home > Web Front-end > JS Tutorial > body text

Two ways to determine whether a text box is empty in js_javascript skills

WBOY
Release: 2016-05-16 18:04:11
Original
2387 people have browsed it
Copy code The code is as follows:

//Username non-null verification
function checkUserName(){
var name = document.myform.txtUser; //Here I think: name represents the text box whose name is txtUser
if(name.value.length==0){
alert("Please Enter username");
name.focus();
return false;
}else{return true;}
}
//Password non-empty verification confirmation verification
function checkPass(){
var pass=document.myform.txtPass;
var rpass=document.myform.txtRPass;
if(pass.value==""){
alert("Password cannot be used is empty");
pass.focus();
return false;
}else if (pass.value.length<4 || pass.value.length>16){
alert( "The length of the password must be 4-16 characters");
pass.select();
return false;
}else if(rpass.value!=pass.value){
alert ("The confirmation password is inconsistent with the password input");
rpass.select();
return false;
}else{return true;}
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template