开发者

MVC 3 - checking if form is valid (has passed client side validation)

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


You could use the following:

if ($('#yourform').valid()) {
    // the form passed client side validation
    // TODO: show busy indicator and disable submit button
}


<script>
    $(function () {
        $(document).on('submit', 'form', function () {
            DisableSubmitButtons();
            console.log("All done");
        });
        });
    function DisableSubmitButtons() {
        $("#backButton").addClass("disabledbutton");
        $("#nextButton").addClass("disabledbutton");
    }


</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜