views:

76

answers:

3

Greetings,

Is there a different between using Ajax and jquery to do input valuation with ASP.NET?

For example,I want to input mask. I can use ajax maskededitextender or jquery masked input plug in to do the mask.

is there a different between using any one of these two??

+1  A: 

jQuery is just a javascript library, and you can use jQuery to issue an AJAX request.

For input validation you won't have to issue an AJAX request. You can handle it on the client side itself. You can use regular expressions for that.

If you want to have a server side validation for your input then you can make an AJAX request.

rahul
+1  A: 

One reason I can think of is that jQuery validation plugins are light weight.Asp.net Ajax toolkits validation controls are heavy as they download lots of script resource files.That said , I always prefer to use plain javascript code snippets to validate uses input data.It helps me in keeping my code clean and gives me more control.Javascript + Regex can be used to validate almost any kind of input data.I prefer to use jQuery , Asp.Net Ajax for more advanced scenarios.

Pawan Mishra
A: 

When you use the Validation controls with ASP.NET the code runs on both the client and the server (it seems not many people know this). This means that if someone uses a tool(such as fiddler) to bypass your client side validation, the validation still runs on the server.

The golden rule is:

Validation on the client for convenience only.

You could further improve the user experience on the client e.g. using jQuery validation plugin but dont forget that you still need to validate on the server.

For me, the ASP.NET validation controls are still a good choice because of this. And if you use an UpdatePanel (Ajax?) the server validation can be quite complex and still provide a good user experience - at the cost of a server roundtrip of course.

James Westgate

related questions