In my HTML file, I have a JavaScript function named "CheckCaptcha". I am using following code line to execute that function when an image is clicked. It is not working. After hours of tweaking and modifying the code, it is not simply reaching to the location where the JavaScript function lies.
I am using this code line:
<input type="image" src="images/join.gif" name="SubmitStudent" onclick="CheckCaptcha();" width="98" height="31"/>
The JavaScript section is as below:
<script type="text/javascript">
function CheckCaptcha()
{
aler("-");
var CaptchaWord;
CaptchaWord = document.getElementById(StudentCaptchaImage);
alert(CaptchaWord);
if (CaptchaWord.length <= 4)
{
alert("Please enter words as seen in the image.");
return false;
}
}
</Script>
Actually, I am a new user, and StackOverflow is avoiding me to post the entire HTML section.
Try this:
function CheckCaptcha()
{
alert("-");
var CaptchaWord = document.getElementById('StudentCaptchaImage');
alert(CaptchaWord);
if (CaptchaWord.value.length <= 4)
{
alert("Please enter words as seen in the image.");
return false;
}
}
.value
attribute contains the value, the DOM element does not have a length
property.If you're not sure of anything you should start alerting as many things as possible..
alert( typeof CaptchaWord.length )