JSFiddle - React, Tailwind, and code Playground
HTML
<form id="form">
<input type="submit" value="Next" id="button1"/>
<input type="submit" value="No validation" id="button2"/>
</form>
JavaScript
$(document).ready(function() {
$("#form").submit(function(e) {
var buttonId = e.originalEvent.explicitOriginalTarget.id;
if (buttonId == "button1") {
//If the status above is false continue to prompt the user if they want to submit or not
var ok = confirm('Do you really want to save your data?');
if (ok) {
return true;
}
else {
//Prevent the submit event and remain on the screen
e.preventDefault();
return false;
}
} else {
alert("No validation.");
}
});
});