jquery validate验证方法

简介: 实例:    equalTo方法 equalTo(其他)返回:布尔说明:要求元素与另一个元素相同等于(其他)其他类型:选择器元素的选择器用于比较当前值例子:使“字段”必须与#other相同1234五678...

实例:

 

 

 

 

equalTo方法

 equalTo(其他)返回:布尔

说明:要求元素与另一个元素相同

例子:

使“字段”必须与#other相同

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
三十
31
32
33
34
35
36
37
38
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Makes "field" required to be the same as #other</title>
<link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css">
 
</head>
<body>
<form id="myform">
<label for="password">Password</label>
<input id="password" name="password" />
<br/>
<label for="password_again">Again</label>
<input class="left" id="password_again" name="password_again" />
<br>
<input type="submit" value="Validate!">
</form>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
$( "#myform" ).validate({
rules: {
password: "required",
password_again: {
equalTo: "#password"
}
}
});
</script>
</body>
</html>

 

相关文章
|
3月前
|
JavaScript CDN
jQuery方法小记
jQuery方法小记
32 0
|
3月前
|
JavaScript
jQuery追加节点方法 和height方法与width方法
jQuery追加节点方法 和height方法与width方法
|
3月前
|
JavaScript 前端开发
调用jQuery的animate()方法无法移动的问题
调用jQuery的animate()方法无法移动的问题
|
3月前
|
JavaScript Serverless
jquery attr()方法
jquery attr()方法
25 0
|
4天前
|
前端开发 JavaScript
jQuery改变元素的方法
jQuery改变元素的方法
6 1
|
4天前
|
存储 JSON JavaScript
jQuery 方法大全
jQuery 方法大全
|
10天前
|
Web App开发 JavaScript Android开发
重载jquery on方法实现click事件在移动端的快速响应
重载jquery on方法实现click事件在移动端的快速响应
|
7天前
|
存储 JSON JavaScript
jQuery 方法大全
jQuery 方法大全
17 0
|
2月前
|
JSON JavaScript 前端开发
jQuery获取json文件的方法
jQuery获取json文件的方法
27 2
|
2月前
|
JavaScript 程序员
老程序员分享:jquery方法总结
老程序员分享:jquery方法总结
19 0