Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Mvc 2 How do you launch client side validation from inside javascript?

Is there a function for ASP.NET MVC 2 built in data annotation javascript validation that performs the functionality of Jquery.Validate's isValid()?

I'd like to check if my fields are valid prior to using jquery ajax to send data to the server? Any suggestions?

Thank You.

like image 808
gt124 Avatar asked May 18 '10 17:05

gt124


People also ask

How can we implement client side validation in ASP.NET MVC?

In the server-side validation, the page must be submitted via a postback to be validated on the server and if the model data is not valid then the server sends a response back to the client with client-side validation, the input data is checked as soon as they are submitted, so there is no postback to the server and ...

How do I make sure client validation is enabled in MVC?

We can enable and disable the client-side validation by setting the values of ClientValidationEnabled & UnobtrusiveJavaScriptEnabled keys true or false. This setting will be applied to application level. For client-side validation, the values of above both the keys must be true.

Where do I put JavaScript code in MVC?

The recommended approach is to put in a separate JavaScript file or inside a section defined in Layout page. A section can be added in the MVC Layout page using @RenderSection() directive. For example, we can define a section in Layout page under <head> tag for scripts like below.


1 Answers

i used the :
http://geekswithblogs.net/stun/archive/2010/02/27/asp.net-mvc-client-side-validation-summary-with-jquery-validation-plugin.aspx
and it worked great for me, especially you don't need to change the original Mvc Validation way(I mean the validation field), you just make it client side

like image 140
Nour Avatar answered Oct 11 '22 17:10

Nour