أمثلة على النحو التالي: أدناه:
نسخ رمز رمز على النحو التالي:
<!
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = gb2312" /> />
<title> رمز التحقق من JS </title>
<type type = "text/css">
.شفرة
{{
صورة الخلفية: url (code.jpg) ؛
Font-Family: Arial ؛
على غرار الخط: مائل ؛
اللون: أحمر.
الحدود: 0 ؛
الحشو: 2px 3px ؛
تباعد الرسائل: 3px ؛
خط الرحلة: أكثر جرأة.
}
.unchangeded
{{
الحدود: 0 ؛
}
</style>
<script language = "javaScript" type = "text/javaScript">
رمز VAR
وظيفة CreateCode ()
{{
الكود = "" ؛
VAR CODENGET = 4 ؛
var checkCode = document.getElementById ("CheckCode") ؛
var selectchar = new array (0،1،2،3،4،5،6،7،8،9 ، 'a' ، 'b' ، 'c' ، 'd' ، 'e' ، 'f' ، 'g' ، 'h' ، 'i' ، 'j' ، 'k' ، 'l' ، 'm' ، 'n' ، 'o' ، 'p' ، 'q' ، 'r' ، 's ، 's' t '،' u '،' v '،' ww '،' x '،' y '،' z ') ؛ يمكنك أيضًا استخدام الصينيين باللغة الصينية
لـ (var i = 0 ؛ i <codength ؛ i ++)
{{
var charindex = math.floor (math.random ()*36) ؛
الكود += selectchar [charindex] ؛
}
// تنبيه (رمز) ؛
إذا (CheckCode)
{{
checkCode.ClassName = "Code" ؛
CheckCode.value = رمز ؛
}
}
قيمة الوظيفة ()
{{
var inputCode = document.getElementById ("input1").
if (inputCode.Length <= 0)
{{
تنبيه ("الرجاء إدخال رمز التحقق!") ؛
}
آخر إذا (inputCode! = رمز)
{{
تنبيه ("خطأ في إدخال رمز التحقق!") ؛
CreateCode () ؛
}
آخر
{{
تنبيه ("موافق") ؛
}
}
</script>
</head>
<body only = "createCode ()" >>
<form action = "#">
<type type = "text" id = "input1" />
<type type = "text" onClick = "CreateCode ()" readonly = "readonly" id = "checkCode" /> <br />
<input id = "button1" onClick = "Valiated () ؛" type = "button"
</form>
</body>
</html>