简体   繁体   中英

Javascript string checking


I am rather new to JavaScript and trying to teach myself javascript form validation.

Would it be possible to get a quick run through of different variables and how to prevent SQL injection?

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. 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. There is a very thorough answer on how to do this server-side in node.js here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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