我是jquery验证器的新手。我一直在这里卡住,需要一些帮助jquery验证器addClassRules方法不适用于所有元素
我有一些input
字段与不同class
为他们每个人。我想通过添加由addClassRules
方法的规则来验证他们使用jquery验证程序。
问题是添加类规则对第一条规则起作用,但之后不起作用。
下面是我的代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple DataTable</title>
<link rel="stylesheet" href="css/bootstrap.css"/>
</head>
<body>
<center>
<div class="container" >
<h1>Welcome to boostrap</h1>
</div>
<form>
<table>
<tr>
<td><input type="text" class="abc"/></td>
<td><input type="text" class="jkl"/></td>
<td><input type="text" class="xyz"/></td>
</tr>
<tr>
<td><input type="text" class="abc"/></td>
<td><input type="text" class="jkl"/></td>
<td><input type="text" class="xyz"/></td>
</tr>
</table>
<input type="submit" />
</form>
</center>
</body>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/jquery.validate.js"></script>
<script>
$(document).ready(function(){
$.validator.addClassRules({
abc:{
required:true
},
jkl:{
required:true
},
xyz:{
required:true
}
});
$("form").validate();
});
</script>
</html>
的文档:
https://jqueryvalidation.org/jQuery.validator.addClassRules/
提到什么我也做了同样的事情。有人能帮助我吗?
优秀。这工作,这是在jquery验证器的文档中提到的? – Chetan
“标记建议”下的第四段:https://jqueryvalidation.org/reference/。 –