Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET: Syncing client and server-side validation rules [closed]

Are there any easy, smart ways to keep your client and server-side validation-rules synchronized?

On the client side we have JavaScript, maybe some kind of framework like jQuery or YUI.

On the server-side we have ASP.NET WebForms or ASP.NET MVC.

What is validated are things like:

  • Correct e-mail-addresses
  • Correct home-addresses and postal codes
  • Correct credit-card numbers

And so on.

like image 799
Seb Nilsson Avatar asked Sep 19 '08 10:09

Seb Nilsson


People also ask

What is the difference between client-side and server side validations in webpages?

When you enter data, the browser and/or the web server will check to see that the data is in the correct format and within the constraints set by the application. Validation done in the browser is called client-side validation, while validation done on the server is called server-side validation.

Why do we need both client-side and server side validation?

Doing input validation on both the client side and server side has a number of benefits: It helps reduce server load since invalid data is never submitted in the first place. It helps prevent malicious users from submitting invalid data.

Which is better client-side validation or server side validation?

Server-side validation is slower than client-side input validation. However, server-side input validation is more reliable than client-side input validation. Thus, it's safe to say that client-side data validation improves user experience while server-side input validation improves security.

How do you disable client-side validation?

To disable client-side validation, set the page's ClientTarget property to 'Downlevel' ('Uplevel' forces client-side validation). Alternatively, you can set an individual validator control's EnableClientScript property to 'false' to disable client-side validation for that specific control.


1 Answers

<asp:RegularExpressionValidator ...> (and the other asp.net validators) implement client side javascript and server side checking to the same rules.

like image 59
ballpointpeon Avatar answered Oct 10 '22 11:10

ballpointpeon