MVC Client Side Validation without preventing form submit

前端 未结 1 1280
無奈伤痛
無奈伤痛 2021-01-27 02:36

I have a form that allows the user to edit my model. They can save the data, as well as publish it. When the user hits save I want to go ahead and save the form even if its doe

相关标签:
1条回答
  • 2021-01-27 02:46

    simply override the form submit and that should disable the validation.

    $(function () {
        $("form").submit(function () {
            if (!$(this).valid()) {
                //form is not valid         
                return true;
            }
        });
    });
    

    You dont need the check there obviously and can just return true, thats just to show you how to check if its valid.

    0 讨论(0)
提交回复
热议问题