Hi ,
We are trying to implement CAPTCHA in portal 7.3 Logon Page.
we are not able to restrict login , when condition return false by using below code. please suggest how to restrict login when captcha is invalid
Jsp Code:
<inputstyle="height:4ex; font-weight:bold; color:black; background-color:#edf2f2;" class="urBtnStdNew"type="submit"name="uidPasswordLogon"value="Login"onclick="ChkKeyboard(false);ValidCaptcha();"/>
Java script:
function DrawCaptcha()
{
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;
}
var captcha_field;
function ValidCaptcha(){
var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('txtInput').value);
var struser = removeSpaces(document.getElementById('logonuidfield').value);
var strpass = removeSpaces(document.getElementById('logonpassfield').value);
if ((struser!=null||strpass!=null)&&(str1==str2))
{
return true;
}
else
{
// captcha invalid
window.alert("Conditionfailed");
return false;
}
}
// Remove the spaces from the entered and generated code
function removeSpaces(string)
{
return string.split(' ').join('');
}
Regards,
Srinivas