JavaScript:客户端与服务器端验证

哪个客户端或服务器端验证更好?

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 条回答