js判断登录文本框是否为空

来源:互联网 发布:磁力链接软件 编辑:程序博客网 时间:2024/05/08 21:27

/**
* 判断文本框是否为空,并且将空格去除
*/
function checkForm(form){
var reg = /^\s*|\s*$/g;
if(form.userid.value.replace(reg,”)==”“){
alert(“请输入用户ID”);
form.userid.value=”“;
form.password.value=”“;
form.userid.focus();
return false;
}
if(form.password.value.replace(reg,”)==”“){
alert(“请输入密码”);
form.password.value=”“;
form.password.focus();
return false;
}
}


0 0
原创粉丝点击