JS version of the random string, suitable for the verification code OH
Source: Internet
Author: User
<!--
--------------------------Random Character--------------------------
Str_0 length
Str_1 is uppercase
str_2 whether lowercase letters
Str_3 whether the number
function Rnd_str (str_0,str_1,str_2,str_3)
{
var seed_array=new array ();
var seedary;
var i;
Seed_array[0]= ""
seed_array[1]= "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";
Seed_array[2]= "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";
seed_array[3]= "0 1 2 3 4 5 6 7 8 9";
if (!str_1&&!str_2&&!str_3) {str_1=true;str_2=true;str_3=true;}
if (str_1) {seed_array[0]+=seed_array[1];}
if (str_2) {seed_array[0]+= "" +seed_array[2];}
if (str_3) {seed_array[0]+= "" +seed_array[3];}
seed_array[0]= seed_array[0].split ("");
Seedary= ""
for (i=0;i<str_0;i++)
{
Seedary+=seed_array[0][math.round (Math.random () * (seed_array[0].length-1))]
}
return (seedary);
}
-->
When--------------------call--------------
<script language= "JavaScript" type= "Text/javascript" >
var obj=document.all.jz_4;
var tmp=rnd_str (6,true,true,true);
obj.value=tmp;
document.write (TMP);
</script>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service