简体   繁体   English

如何同时使用jquery和Server端验证客户端?

[英]how to Validate Client Side with jquery and Server side at same time?

i really love the jquery validation plugins, look neat stylish and accessible, but as you know JavaScript can be turned off and boom your user can enter what ever he wants, therefore you should validate on server too, so what is the best approach here ? 我真的很喜欢jquery验证插件,看起来整洁时尚且易于访问,但是你知道JavaScript可以关闭并且繁荣你的用户可以输入他想要的东西,因此你也应该在服务器上验证,那么这里最好的方法是什么?

do double validation one with jquery and one on server side or is there a better solid secure way ? 用jquery进行双重验证,在服务器端进行一次验证,还是有更好的可靠安全方法?

The only way to go is to validate with jQuery and then do the same validation again on the server side. 唯一的方法是使用jQuery进行验证,然后在服务器端再次执行相同的验证。

Client side validation is only for making your application more user friendly. 客户端验证仅用于使您的应用程序更加用户友好。 So validate the fields that will save the user some round-trips to the server and that will contribute to a better user experience. 因此,验证将为用户节省一些往返服务器的字段,这将有助于提高用户体验。

Always validate on the server side. 始终在服务器端验证。 This protects you from attacks to your application. 这可以保护您免受对应用程序的攻击。 It also helps from feeding erroneous input to your code. 它还有助于将错误的输入提供给您的代码。

Well double validation is probably the only way to go - if the user disables javascript, then no validation will be executed on the client side, therefore you MUST have server side validation. 双重验证可能是唯一的方法 - 如果用户禁用javascript,那么将不会在客户端执行验证,因此您必须具有服务器端验证。 On the other hand - for the convenience of most users - there should be a client side validation mechanism so that round-trips to the server are minimized. 另一方面 - 为了方便大多数用户 - 应该有一个客户端验证机制,以便最小化到服务器的往返。

That's why I still use the Asp.Net validation. 这就是我仍然使用Asp.Net验证的原因。 Because, with a minimal effort your data will be validated on the client and server. 因为,只需很少的工作量,您的数据就可以在客户端和服务器上进行验证。

您应始终验证您的数据服务器端,jQuery与否,永远不要信任传入的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM