I keep getting this error saying that it cannot find my javascript function checkpw(). It’s being called by onfocus.
<script type="text/javascript" >
function checkpw() {
alert ("working");
}
</script>
</head>
<body>
<h2>Welcome to our webpage.</h2>
<p>{{ reginfo}}</p>
<form action="/validate/" method ="get" >
<p>Username</p>
<input type="text" name="username" class="textbox"> </input > </br>
<p>Password</p>
<input class="textbox" name="password" id="password" type="text"> </input > </br>
<p>Confirm Password</p>
<input class="textbox" id="checkpw" type="text" onfocus="checkpw()"> </input > </br>
<p>Email<p>
<input class="textbox" name="email" type="text"> </input > </br>
<input type="submit" class="button" value="Submit">
</form>
</body>
I’m probably making a really stupid mistake but i’m new to javascript so anything that helps would be great. thanks.
change:
function checkpw()to:function checkPw()and:
focus="checkpw()"to:focus="checkPw()"Edit:
It is not a reserved word; however the name is already polluted in the global namespace. As Domenic and jimr pointed out, the
idattribute is using the same name, thus causing a conflicting condition.The solution is still to change either:
(1) the
idvalue of the input element-or-
(2) the function name (as I stated above)