A validation() function needs to be called whenever a form is submitted which validates the input and based on that returns true or false. But based on two submit buttons there are two validation() functions. Here is an example
<form name="abc" id="abc" method="post" onsubmit="return validate()">
<button type="submit" id="save">Save</button>
<button type="submit" id="edit">Edit</button>
</form>
<script type = "text/javascript">
document.getElementById("save").onclick = function() {
validateSave();
}
document.getElementById("edit").onclick = function() {
validateEdit();
}
function validateSave(){
//do validation
}
function validateEdit(){
//do validation
}
function validate(){
//return true or false based on the validation
}
</script>
So basically I want to use onsubmit="return validate() weather to navigate to next page or remain in the same page. So how to use the onsubmit="return validate() alongwith the respective validation on basis of the button clicked.
Any leads/hint would be appreciated. Thanks