开发者

Detect if asp.net mvc2 client side validation passes or fails

All... I am working in a asp.net mvc2 project using MicrosoftMvcValidation...

I have some custom javascript that I need to run when a form gets posted... I am currently running this code when the submit button is clicked. However, when the client side validation fails I do not want to run the code.

I see this article on hooking into the validation but am unable to get it working. ASP.NET MVC2 - hook into client side validation

Does anyone have advice on how to achieve the following.

When submit button pressed and client validation passes... run my custom code

When submit button pressed 开发者_高级运维and client validation fails... do not run my custom code


u can use jquery validate like this $('#your_form_Id').valid() this will check if the form is valid and will return true if valid or else returns false.

See here the documentation : http://docs.jquery.com/Plugins/Validation/valid .


I would use jQuery for unobtrusive client-side validation. Take a look at this, it will help you get through what you're looking for

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜