Sachu
Sachu

Reputation: 7766

.Submit() in jquery not firing

i am having a razor code as below

        @using (Html.BeginForm("OtherUpdateRequest", "Members", FormMethod.Post,
 new { name = "form1", id = "form1", enctype = "multipart/form-data" }))
     {
    .......
<input type="button" value="Update Members" name="update" id="update" class="btn btn-success">

    }

and in script area after some validation the form is getting submitted as below

 $("#update").on('click', function () {
......
            if (error == 0)
            {
                alert(error);
                $("#errorDiv").hide();
                $("#form1").submit();
            }
});

it is alerting the value of error. SO it is getting inside the if condition but the form is not getting submitted.

If i change the input code as below it will get submitted but i need some jquery validation so the submit can only done through jquery. Please let me know anything wrong I am doing.

    <input type="Submit" value="Update Members" name="update" id="update" 
class="btn btn-success">

Also if I place Submit() above the alert statement the alert also won't work..

$("#update").on('click', function () {
    ......
                if (error == 0)
                {
                    $("#form1").submit();
                    alert(error);
                    $("#errorDiv").hide();

                }
    });

Upvotes: 0

Views: 1392

Answers (1)

Anik Islam Abhi
Anik Islam Abhi

Reputation: 25352

Try like this

$("form#form1")[0].submit();

Upvotes: 1

Related Questions