【JS】验证表单是否空白验证
<form action="main.html" id="loginForm" name="loginForm" onsubmit="return checkLogin()">
<p class="logo" width="100x">XX系统管理系统</p><br>
<input name="username" type="tel" class="Input" placeholder="用户名" value=""><br>
<input name="passwd" type="password" class="Input" placeholder="密码" value=""><br>
<button class="botton" id="loginbutton">登陆</button>
</form>
function checkLogin() {
// alert("提交表单检查")
//检查表单是否填写了数据
username=document.loginForm.username.value;
passwd=document.loginForm.passwd.value;
if(username==""||passwd==""){
alert("用户名或密码为空!");
return false;
}else {
return true
}
}
本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/16329182.html