简体   繁体   English

JavaScript字符串检查

[英]Javascript string checking


I am rather new to JavaScript and trying to teach myself javascript form validation. 我是JavaScript的新手,试图自学javascript表单验证。

Would it be possible to get a quick run through of different variables and how to prevent SQL injection? 是否可以快速浏览不同的变量,以及如何防止SQL注入?

I am currently using the variable to test if my passwords match some level of security. 我目前正在使用变量来测试我的密码是否符合某种级别的安全性。 Would it be possible to see an example variable that requires a user to enter at least one number and at least one Upper case letter mixed in with their other lowercase letters. 是否有可能看到一个示例变量,该变量要求用户输入至少一个数字至少一个大写字母以及其他小写字母。

var passw= /^[a-zA-Z]*.{8,15}$/;

Much obliged and thanks very much 非常有义务,非常感谢

If you're trying to prevent SQL injection, then you need to do it server-side. 如果要防止SQL注入,则需要在服务器端进行。 Doing it client-side is pointless, because it is fairly trivial for some evil-doer to intercept the requests and change the values, bypassing your client-side validation. 在客户端执行此操作是没有意义的,因为对于某些邪恶的人来说,拦截请求并更改值(绕过客户端验证)是相当琐碎的。

With that said, if you're using node.js or some other javascript based server-side engine, then you can do your validation there. 话虽如此,如果您使用的是node.js或其他基于JavaScript的服务器端引擎,则可以在此处进行验证。 There is a very thorough answer on how to do this server-side in node.js here . 有关于如何做的node.js这个服务器端的一个非常完整的答案在这里

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

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