<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"
}
});
});
});
What I want is; when I submit the formSubmit
button I want form to not validate, but when I click submitAndConfirm button I want validate the form to be validated.
<script>
$(document).ready(function(){
...
});
</script>
Anyway, I would check it with 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
};
};
?>
you can try this if I have completely understood the problem.
when you want a form to be saved by a button and to be submitted by a another button, you have to use the attribute "formnovalidate" at the end of the buttton as bellow:
<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>
Try this
$(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"
}
});
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.