MVC 3 - checking if form is valid (has passed clie

2020-03-01 10:41发布

I am using out of the box client side validation in MVC 3. At the client side, I want to detect if the form has passed client side validation. If so I want to display an busy indicator and disable the 'submit' button.

So I am looking for a form.isValid type property of a collection of error that I can query from js.

Any pointers.

Thanks

Pj

2条回答
Anthone
2楼-- · 2020-03-01 11:21

You could use the following:

if ($('#yourform').valid()) {
    // the form passed client side validation
    // TODO: show busy indicator and disable submit button
}
查看更多
劳资没心,怎么记你
3楼-- · 2020-03-01 11:22
<script>
    $(function () {
        $(document).on('submit', 'form', function () {
            DisableSubmitButtons();
            console.log("All done");
        });
        });
    function DisableSubmitButtons() {
        $("#backButton").addClass("disabledbutton");
        $("#nextButton").addClass("disabledbutton");
    }


</script>
查看更多
登录 后发表回答