服务器端/客户端或两个用户输入验证

问题描述:

什么是使用验证您的网站时,我想给人客户端的帮手的验证,如密码不够长的最佳方式,电子邮件是不正确的格式,但也做服务器端验证并返回错误,如用户名已经存在,并且具有客户端和服务器验证消息目测显示相同的与复制的最小量的用户。

What is the best way to use validation on your site when I want to give people client side "helper" validation such as password not long enough, email is incorrect format but also do server side validation and return errors such as username already exists and have both client and server validation messages visually be displayed the same to the user with the minimal amount of duplication.

客户端验证可以很容易规避。您应始终验证服务器的敏感数据,而不管客户端验证。验证他们的客户也只是一个改进的用户体验问题。

Client validation can be circumvented easily. You should always validate sensitive data on server, regardless of client validation. Validating them on client too is just a matter of improved user experience.

BTW,ASP.NET验证控件两者都做。

BTW, ASP.NET validation controls do both.