In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how JS can generate CAPTCHA randomly. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The details are as follows
111111 can't see another CAPTCHA: make sure var arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" "a", "b", "c", "d", "e", "f", "g", "h", "I", "j", "k", "l", "m", "n", "o", "p", "Q", "r", "s", "t", "u", "v", "w", "x", "y", "z", 0r 1, 3, 4, 6, 7, 8] Var h2=document.querySelector ("H2"); var btn=document.querySelector ("button"); var change=document.querySelector ("a"); var input=document.querySelector ("input"); function fn () {var arr1=Math.floor (Math.random () * 62); var arr2=Math.floor (Math.random () * 62); var arr3=Math.floor (Math.random () * 62) Var arr4=Math.floor (Math.random () * 62); var arr5=Math.floor (Math.random () * 62); var arr6=Math.floor (Math.random () * 62); var yz= "+ arr [arr1] + arr [arr2] + arr [arr3] + arr [arr4] + arr [arr5] + arr [arr6]; H2 [XSS _ clean] = yz; btn.onclick=function () {alert (input.value) If (input.value==yz) {alert (correct);} else {alert (error);} fn (); change.addEventListener ("click", fn)
1. Math.floor () method
Math.floor (x)
The floor () method returns the largest integer less than or equal to x.
If the parameter passed is an integer, the value remains the same.
2. Math.random () method
The random () method returns a random number between 0 (inclusive) and 1 (not inclusive).
The function of taking random numbers can be realized by using the above two methods.
Thank you for reading! This is the end of the article on "how to randomly generate CAPTCHA in JS". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.