Which is better to do client side or server side validation?


In our situation we are using

  • jQuery和MVC。

  • 在View和Controller之间传递的JSON数据。

例如,我使用 keypress 事件来防止文本框中的字母,设置最大字符数以及数字在某个范围内。

A lot of the validation I do is validating data as users enter it. For example I use the the keypress event to prevent letters in a text box, set a max number of characters and that a number is with in a range.


I guess the better question would be, Are there any benefits to doing server side validation over client side?


Awesome answers everyone. The website that we have is password protected and for a small user base(<50). If they are not running JavaScript we will send ninjas. But if we were designing a site for everyone one I'd agree to do validation on both sides.

 1 条回答