<!DOCTYPE html>
<html>
<head>
<title>form-validate-demo</title>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/additional-methods.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/additional-methods.min.js"></script>
</head>
<body>
<form action="#" method="POST" id="form_validate">
<label>名字:<input type="text" id="name" name="name"></label>
<label for="">
<input type="submit" value="submit">
</label>
</form>
<script>
$('#form_validate').validate({
rules: {
name: {
required: true,
minlength: 2,
maxlength: 5
}
},
submitHandler: function(form){
$.ajax({
...
});
},
})
</script>
</body>
</html>
Jquery插件- form表单的验证
最新推荐文章于 2019-06-05 08:47:23 发布