javaScript 判断数值的合法性

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录</title>
<script type="text/javascript">
function checkAction() {
var user_name = document.getElementById("phone").value;
var pasWord = document.getElementById("passWord").value;

if(user_name.length==0||user_name==null)
{
alert("user_name is valid");
return false;
}else if(pasWord.length==0||pasWord==null)
{
alert("pasWord is valid");
return false;
}
else
{
return true;
}
}

</script>
</head>
<body>
<form action="loginTools.jsp" name="form">
手机号码<input type="text" name="phone" id="phone"/>
密码<input type="passWord" name="passWord" id="passWord"/>

<input type="submit" value="提交" onclick="return checkAction(this)"/>
</form>
</body>
</html>
posted @ 2017-02-27 17:14  tiankongzhicheng  阅读(229)  评论(0编辑  收藏  举报