3

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

Community
  • 1
  • 1
Todd
  • 1,401
  • 1
  • 13
  • 27

2 Answers2

1

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 .

Claudiu
  • 217
  • 3
  • 12
0

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

PsychoCoder
  • 9,900
  • 12
  • 40
  • 60