<form>
<input type="submit" name="submit" id="formSubmit" value="SAVE FOR NOW" />
<input type="submit" name="submitAndConfirm" id="submitAndConfirm" value="CONFIRM AND UPLOAD TO SERVER" />
</form>
$(document).ready(function(){
$('#addPat').submit();
$('#submitAndConfirm').click(function(){
$('#addPat').validate({
rules:{
iscosId:{required:true},
pat_id:{required:true},
admissionDate:{required:true},
dischargePlace:{required:true}
},messages:{
iscosId:"Please reload the Page",
pat_id:"This field cannot be empty",
admissionDate:"This field cannot be empty",
dischargePlace:"This field cannot be empty"
}
});
});
});
我想要的是;当我提交formSubmit
按钮时,我希望表单不验证,但是当我单击submitAndConfirm按钮时,我想验证要验证的表单。
答案 0 :(得分:0)
<script>
$(document).ready(function(){
...
});
</script>
无论如何,我会用php检查它。
<?php
if (isSet($_POST['submit'])) {
if ($_POST['submit'] == "SAVE FOR NOW") {
//Your PHP testing & action code
} else { //or elseif ($_POST['submit'] == "CONFIRM AND UPLOAD TO SERVER"
//Your PHP code
};
};
?>
答案 1 :(得分:0)
如果您希望通过按钮保存表单并通过其他按钮提交,则必须使用属性&#34; formnovalidate&#34;在buttton的尽头,如下:
<form action="" method="get" novalidate>
<p><label for="Text1" >First Name: </label><input name="Text1" type="text" required></p>
<p><label for="Text2">Last Name: </label><input name="Text2" type="text"></p>
<p><label for="Text3">Favorite Color: </label><input name="Text3" type="text"></p>
<p><input name="Submit1" type="submit" value="submit"> </p>
<p><input name="Save" type="button" value="save" formnovalidate> </p>
</form>
答案 2 :(得分:0)
试试这个
$(document).ready(function(){
$('#formSubmit').click(function(){
$('#addPat').submit();
});
$('#submitAndConfirm').click(function(){
$('#addPat').validate({
rules:{
iscosId:{required:true},
pat_id:{required:true},
admissionDate:{required:true},
dischargePlace:{required:true}
},messages:{
iscosId:"Please reload the Page",
pat_id:"This field cannot be empty",
admissionDate:"This field cannot be empty",
dischargePlace:"This field cannot be empty"
}
});
});
});