简体   繁体   English

jQuery表单验证:如果用户禁用javascript怎么办?

[英]jquery form validation: what if the user disables javascript?

I used jQuery form validation to make sure the data entered by the user are of correct format. 我使用jQuery表单验证来确保用户输入的数据格式正确。 However, the user may disable his/her browser's javascript and enters garbage data. 但是,用户可能禁用他/她的浏览器的javascript并输入垃圾数据。 How can I solve this problem? 我怎么解决这个问题?

It is always a good practise to do serverside validation also.Don't depend on client too much. 最好也进行serverside验证。不要太依赖客户端。

You SHOULD NOT assume the validation successfully done at client side is 100% perfect. 您不应假定在客户端成功完成验证是100%完美的。 No matter even if it serves less than 50 users. 即使服务的用户少于50个,也是如此。 You never know which of your user/emplyee turn into an "evil" and do some harmful activity knowing you dont have proper validations in place. 您永远都不知道您的哪个用户/员工变成了“邪恶”,并且知道自己没有适当的验证,因此会进行一些有害的活动。

I recommend you to go through: JavaScript: client-side vs. server-side validation 我建议您通过以下步骤: JavaScript:客户端与服务器端验证

If you want to force the user to use JavaScript, you can use 如果要强制用户使用JavaScript,可以使用

<body>

<noscript>
Javascript is disabled.
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourweb.com/message_page"> 
</noscript>

</body>

HTML 5 have some validation features, but most of the modern browser doesn't fully support it. HTML 5具有一些验证功能,但是大多数现代浏览器并不完全支持它。

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

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