I have 5 different forms where I am disabling the submit button when a valid form is submitted so the form can only be submitted once. I am using a hidden field on each form to get the form Id.
function OnSubmit(buttonId) {
var disableButton = false;
if ($('#formType').val() == 1) {
if ($('#CreateEntityName').val() != "" && $('#newAccountGroup').val() != "") {
disableButton = true;
}
}
if ($('#formType').val() == 2) {
if ($('#newAccount').val() != "" && $('#lastName').val() != "") {
disableButton = true;
}
}
if ($('#formType').val() == 3) {
if ($('#select2-entityId').val() != 0 && $('#contact').val() != "") {
disableButton = true;
}
}
if ($('#formType').val() == 4) {
if ($('#select2-entityId').val() != 0 && $('#contact').val() != "" && $('#need').val() != "" && $('#candidates').val() != 0) {
disableButton = true;
}
}
if ($('#formType').val() == 5) {
if ($('#newAccount').val() != "" && $('#country').val() != "") {
disableButton = true;
}
}
if (disableButton == true) {
$('#' + buttonId + '').attr("disabled", true);
}
}
@Html.Hidden("formType", 5)