js made random codes 8

  Development ideas:

  Draw placement verification code module, a written "see ..." pieces, and the codes of the input text box

  Acquisition modules

  A function package Yan_ma (), to set the authentication code 8, which contains digital, lowercase letters, lower case letters and Chinese. The possibility of occurrence of each type was 25%.

  0-9 random numbers between. Of Math.ramand () it rounds down.

  Case letters using the fromCharCode random () method: a character into Unicode encoding, for example:

  var n = String.fromCharCode(65);

  cosole.log(n);

  A result is output // j

  Uppercase letters (65-91) lowercase letters (97-123)

  var s = String.fromCharCode(Math.floor(Math.random() * 26 + 65));

  var s = String.fromCharCode(Math.floor(Math.random() * 26 + 97));

  Random Chinese, declare a variable letter placed Chinese string, use charAt () to get a random letter in Chinese characters.

  var letter = "executive sum Su Jian Yin life for you to do thousands of back then it Should be darling please promise me under the lamp in ink";

  var s = letter.charAt(Math.floor(Math.random() * letter.length));

  Codes provided to each random color, font size, text position relative rotational angle. Color function to a package, using a hexadecimal color (eg: #ffffff)

  //random color

  function fontcolor(){

  var s1="";

  for (var k = 0; k <6; k ++) {

  var z=[0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"];

  var m=z[Math.floor(Math.random() * z.length)];

  s1 +=m;

  } Wuxi abortion how much money http://mobile.bhnfkyy.com/

  return "#"+s1;

  }

  The same random positions and random rotation angles Method

  8px random positions may be shifted vertically and horizontally, may be random rotation angle around the z-axis (± 45 °).

  An empty string str declare in advance so that each code string connected.

  var s = String.fromCharCode(Math.floor(Math.random() * 26 + 97));

  str+=""+s+"";

  arr+=s;

  Let 8 innerHTML code appears in the first large module in.

  To read, "see" the span tag to add a click event, when clicked, call the function Yan_ma, refresh verification codes.

  If you enter a verification code is not correct, then the pop-up "verification success", or pop-up "Authentication failed."

  See ...

  verification

Guess you like

Origin www.cnblogs.com/djw12333/p/11002475.html