jQuery 打开我的表单操作,而不是在不更改页面的情况下提交表单。我现在正在工作的是,我不希望在提交表单时刷新页面,因为我想在提交/加载时集成进度条。感谢您的帮助。
这是我用于验证和重定向的 jQuery:
<script type="text/javascript" src="../javascript/jquery.js"></script>
<script type="text/javascript" src="../javascript/jquery.validate.js"></script>
<script type="text/javascript" src="../javascript/jquery.form.js"></script>
<script type="text/javascript">
$('document').ready(function(){
$('#form').validate({
rules:{
"fname":{
required:true,
maxlength:40
},
"lname":{
required:true,
maxlength:40
},
"mobile":{
required:true,
number: true
},
"address":{
required:true
},
"year":{
required:true
},
"month":{
required:true
},
"day":{
required:true
},
"files": {
accept:"jpg,png,jpeg,gif"
},
"vid": {
accept: "ogg|ogv|avi|mpe?g|mov|wmv|flv|mp4"
}},
messages:{
"fname":{
required:"First Name is required"
},
"lname":{
required:"Last Name is required"
},
"mobile":{
required:"Mobile is required"
},
"address":{
required:"Address is required"
},
"files":{
accept: "Please choose a valid image file (jpg/png/jpeg/gif)"
},
"vid" : {
accept: "Please choose a valid video file (ogg/ogv/avi/mpg/mpeg/mov/flv/mp4)"
}}
submitHandler: function(form){
$(form).ajaxSubmit({
target: '#preview',
success: function() {
//$('form').find('input[type=text], select,input[type=file]').val('');
// }
});
}
})
});
这是我的表格的一部分:
<form id="form" name="form" action="submit_video.php" method="POST" enctype="multipart/form-data">
</form>