<script type="text/javascript">
function checkform(theform){ var why = ""; if(theform.txtInput.value == ""){ why += "کد امنیتی نباید خالی باشد\n"; } if(theform.txtInput.value != ""){ if(ValidCaptcha(theform.txtInput.value) == false){ why += "- کد امنیتی اشتباه است\n"; } } if(why != ""){ alert(why); return false; } }
//Generates the captcha function var a = Math.ceil(Math.random() * 9)+ ''; var b = Math.ceil(Math.random() * 9)+ ''; var c = Math.ceil(Math.random() * 9)+ ''; var d = Math.ceil(Math.random() * 9)+ ''; var e = Math.ceil(Math.random() * 9)+ ''; var code = a + b + c + d + e; document.getElementById("txtCaptcha").value = code; document.getElementById("txtCaptchaDiv").innerHTML = code;
// Validate the Entered input aganist the generated security code function function ValidCaptcha(){ var str1 = removeSpaces(document.getElementById('txtCaptcha').value); var str2 = removeSpaces(document.getElementById('txtInput').value); if (str1 == str2){ return true; }else{ return false; }}
// Remove the spaces from the entered and generated codefunction removeSpaces(string){ return string.split(' ').join('');}
</script>
<p>
<label for="code">کد رو به رو را وارد کنید > <span id="txtCaptchaDiv" style="color:#F00"></span><!-- this is where the script will place the generated code --> <input type="hidden" id="txtCaptcha" /></label><!-- this is where the script will place a copy of the code for validation: this is a hidden field --> <input type="text" name="txtInput" id="txtInput" size="30" />
</p>
با رفرش کردن صفحه کد امنیتی تغییر می کند
<script type="text/javascript">
function checkform(theform){ var why = ""; if(theform.txtInput.value == ""){ why += "کد امنیتی نباید خالی باشد\n"; } if(theform.txtInput.value != ""){ if(ValidCaptcha(theform.txtInput.value) == false){ why += "- کد امنیتی اشتباه است\n"; } } if(why != ""){ alert(why); return false; } }
//Generates the captcha function var a = Math.ceil(Math.random() * 9)+ ''; var b = Math.ceil(Math.random() * 9)+ ''; var c = Math.ceil(Math.random() * 9)+ ''; var d = Math.ceil(Math.random() * 9)+ ''; var e = Math.ceil(Math.random() * 9)+ ''; var code = a + b + c + d + e; document.getElementById("txtCaptcha").value = code; document.getElementById("txtCaptchaDiv").innerHTML = code;
// Validate the Entered input aganist the generated security code function function ValidCaptcha(){ var str1 = removeSpaces(document.getElementById('txtCaptcha').value); var str2 = removeSpaces(document.getElementById('txtInput').value); if (str1 == str2){ return true; }else{ return false; }}
// Remove the spaces from the entered and generated codefunction removeSpaces(string){ return string.split(' ').join('');}
</script>
<p>
<label for="code">کد رو به رو را وارد کنید > <span id="txtCaptchaDiv" style="color:#F00"></span><!-- this is where the script will place the generated code --> <input type="hidden" id="txtCaptcha" /></label><!-- this is where the script will place a copy of the code for validation: this is a hidden field --> <input type="text" name="txtInput" id="txtInput" size="30" />
</p>
<label for="code"><span id="txtCaptchaDiv" style="color:#F00"></span> < کد رو به رو را وارد کنید
<input type="hidden" id="txtCaptcha" /></label>
<input type="text" name="txtInput" id="txtInput" size="30" />
<script type="text/javascript">
function checkform(theform){
var why = "";
if(theform.txtInput.value == ""){
why += "- Security code should not be empty.\n";
}
if(theform.txtInput.value != ""){
if(ValidCaptcha(theform.txtInput.value) == false){
why += "- Security code did not match.\n";
}
}
if(why != ""){
alert(why);
return false;
}
}
//Generates the captcha function
var a = Math.ceil(Math.random() * 9)+ '';
var b = Math.ceil(Math.random() * 9)+ '';
var c = Math.ceil(Math.random() * 9)+ '';
var d = Math.ceil(Math.random() * 9)+ '';
var e = Math.ceil(Math.random() * 9)+ '';
var code = a + b + c + d + e;
document.getElementById("txtCaptcha").value = code;
document.getElementById("txtCaptchaDiv").innerHTML = code;
// Validate the Entered input aganist the generated security code function
function ValidCaptcha(){
var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('txtInput').value);
if (str1 == str2){
return true;
}else{
return false;
}
}
// Remove the spaces from the entered and generated code
function removeSpaces(string){
return string.split(' ').join('');
}
</script>