jquery表单验证插件validation使用方法详解
时间:2021-01-02 15:12:49|栏目:jquery|点击: 次
一、如何使用
引入js文件
<script src="jquery.js"></script> <script src="jquery.validate-1.13.1.js"></script>
编写html页面,这里仅以用户名、密码为例
<body>
<form id="demoForm">
<fieldset>
<legend>用户登录</legend>
<p>
<label for="username">用户名</label>
<input type="text" id="username" name="username">
</p>
<p>
<label for="password">密码</label>
<input type="text" id="password" name="password">
</p>
</fieldset>
</form>
</body>
编写script脚
$(document).ready(function(){
$("#demoForm").validate({
rules:{
username:{
required:true,// 是否必填
minlength:2, // 最小长度
maxlength:10 // 最大长度
},
password:{
required:true,
minlength:2,
maxlength:16
}
}
});
});
二、测试

如果大家还想深入学习,可以点击两个精彩的专题:jquery表单验证大全 JavaScript表单验证大全
上一篇:jQuery中[attribute*=value]选择器用法实例
栏 目:jquery
下一篇:jQuery插件echarts实现的单折线图效果示例【附demo源码下载】
本文标题:jquery表单验证插件validation使用方法详解
本文地址:http://www.codeinn.net/misctech/39555.html






