JSP 检测输入筐是否为空,有问题

来源:百度知道 编辑:UC知道 时间:2024/06/20 00:16:45
以下是我的代码,不知道是否检测了,提示框出不来,请高手帮看看咋回事,

<SCRIPT language="JavaScript">
function isEmpty(str)
{
if((str==null)||(str.length==0))
{
return ture;
}
else
{
return(false);
}
}
function check()
{
var userid=window.document.form1.userid.value;
if(isEmpty(userid))
{
alert("请输入登录名");
window.document.form1.userid.focus();
return false;
}
var userpass=window.document.form1.userpass.value;
if(isEmpty(userpass))
{
alert("请输入密码");
window.document.form1.userpass.focus();
return false;
}
return true;
}

</SCRIPT>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登陆信息</title>
</head>
<style type="text/css">
<!--@import "css/jsp.css";-->

function isEmpty(str)
{
if((str==null)||(str.length==0))
{
return ture;
}
那个ture有问题.是true而不是ture...
return true;

何必要写成这样嘛,给你个js,引入进来用就是了,留下邮箱