1. First create an input box for the user to enter a verification code and a span container to hold the system given the verification code and a refresh button and a login button
class= "DL" id= "Sryzm" /><br/><span id= "Ysyzm" style= "Color:white ; font-weight:bolder ; font-size:18px; min-width:70px "></span>
<input id= "Sxyzm" type= "button" class= "btn Btn-default" value= "Refresh" style= "font-weight:200"/>
<input type= "button" class= "btn Btn-default" id= "btn" value= "Login" style= "Font-weight:bolder"/>
2.JS Code
1<script type= "Text/javascript" >2 varYsyzm = "";//Original Verification Code3 varSryzm = "";//Input Verification Code4$ (document). Ready (function(e) {//Page one load complete on execution method5 6 varstr = "QGFH12KJQWFEFEW3ESAEWE544SSGW6GGGGU5MWEE6777EEWW7B67FEC";7 varn = 5, s = "";8 for(vari = 0; I < n; i++){9 var Rand= Math. Floor(Math.random () * str.length);Ten Ones + = Str.charat (Rand); A } -$ ("#ysyzm").HTML (s); -Ysyzm =s; the -$ ("#sxyzm"). Click (function() {//To refresh button plus Click event - -S= ""; + - for(vari = 0; I < n; i++){ + var Rand= Math. Floor(Math.random () * str.length);//Specify selection location As + = Str.charat (Rand);//Specify selection characters at - /*the random () method can return a random number between 0 and 1. - Math.floor A mathematical function, the floor of a floating-point number is the one nearest to it, whose value is less than or equal to the floating-point. - The charAt (int index) method is a method that can be used to retrieve a string instance of a character under a specific index. - the CharAt () method returns a char value at the specified index position. The index range is 0~length () -1. - such as: Str.charat (0) retrieves the first character in Str, Str.charat (Str.length ()-1) retrieves the last character.*/ in - } to$ ("#ysyzm").HTML (s); +Ysyzm =s; - the }); * $ Panax Notoginseng -$ ("#btn"). Click (function() {//Add click event to login button theSryzm = $ ("#sryzm").Val (); + //take username and password A varA = $ ("#uid").Val (); the varB = $ ("#pwd").Val (); + varAA = Ysyzm.toLowerCase ();//In order to implement the input is not case-sensitive, in comparison, the original verification code and input verification code are converted to lowercase letters can be - varbb = Sryzm.toLowerCase (); $ if(aa==BB)//Two verification code to compare, if the same time, execute the following code ${alert (123)}
Native JS Write verification code