js数据验证集合、js email验证、js url验证、js长度(2)


<html>
<head>
<title>网页标题</title>
<script type="text/javascript" src="https://www.jb51.net/test.js"></script>
<script type="text/javascript">
function checkForm(){
var isPass = true;
//过滤字符串
if(!(checkData.isEmptySpan("filterStr") && checkData.filterStrSpan('filterStr','#$%$'))) {
isPass = false;
}
//检查url
if(!(checkData.isEmptySpan("isURL") && checkData.isURLSpan('isURL')))
isPass = false;
//email
if(!(checkData.isEmptySpan("isEmail") && checkData.isEmailSpan('isEmail')))
isPass = false;
//数字
if(!(checkData.isNumSpan('isNum')))
isPass = false;
//数字大小
if(!(checkData.isEmptySpan("isRangeNum") && checkData.isNumSpan('isRangeNum') && checkData.isRangeNumSpan('isRangeNum',10,100)))
isPass = false;
//密码 (数字,字母,下划线)
if(!(checkData.isLicitSpan('isLicit')))
isPass = false;
//二个字段是否相等
if(!(checkData.isEmptySpan("isEquals") && checkData.isEqualsSpan('isEquals','isEquals1')))
isPass = false;
//字符长度控制
if(!(checkData.isRangeSpan('isRange',5,10)))
isPass = false;
//字符最短控制
if(!(checkData.isLessSpan('isLess',10)))
isPass = false;
//字符最长控制
if(!(checkData.isEmptySpan("isMore") && checkData.isMoreSpan('isMore',30)))
isPass = false;
//为空控制
if(!(checkData.isEmptySpan("isEmpty")))
isPass = false;
return isPass;
}
</script>
</head>
<body>
<form action="index.jsp" method="post" onsubmit="return checkForm();">
<table>
<tbody>
<tr>
<td>字符过滤:<input type="text"></td>
<td>链接:<input type="text"></td>
</tr>
<tr>
<td>邮件:<input type="text"></td>
<td>数字:<input type="text"></td>
</tr>
<tr>
<td>数字范围:<input type="text"></td>
<td>a-zA-Z0-9_<input type="text"></td>
</tr>
<tr>
<td>判断相等:<input type="text"></td>
<td><input type="text"></td>
</tr>
<tr>
<td>长度控制:<input type="text"></td>
<td>长度大于控制:<input type="text"></td>
</tr>
<tr>
<td>长度小于控制:<input type="text"></td>
<td>是否为空:<input type="text"></td>
</tr>
<tr>
<td><input type="submit" value="提交数据"></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdxspg.html