简单实用的反馈表单无刷新提交带验证

表单无刷新提交验证,非常适用于反馈,具体的实现如下包含各个功能代码,喜欢的朋友可以参考下

js文件可以查看源码

XML/HTML Code

复制代码 代码如下:


<div></div>
<div>
<form action="submit.php" method="post">
<ul >
<li>
<label>Name</label>
<input type="text" maxlength="40" />
</li>
<li>
<label>Email</label>
<input type="text" maxlength="100" />
</li>
<li>
<label>Message</label>
<textarea rows="5" cols="45"></textarea>
</li>
<li>
<label> </label>
<input type="submit" value="Submit">
</li>
</ul>
</form>
</div>


JavaScript Code

复制代码 代码如下:


<script type="text/javascript">
$('document').ready(function(){

$('#form').validate({
rules:{
"name":{
required:true,
maxlength:40
},

"email":{
required:true,
email:true,
maxlength:100
},

"message":{
required:true
}},

messages:{
"name":{
required:"This field is required"
},

"email":{
required:"This field is required",
email:"Please enter a valid email address"
},

"message":{
required:"This field is required"
}},

submitHandler: function(form){
$(form).ajaxSubmit({
target: '#preview',
success: function() {
$('#formbox').slideUp('fast');
}
});

}

})

});
</script>

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

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