JSF CommandButton onclick does not call Javascript function
- Check your generated code (open the page -> view source)
- Check your javascript console (Firefox) for errors
- make sure your function is callable from a normal
<input type="button">
- lowercase your button type.
Otherwise, it should work - I have exactly the same piece of code in my current codebase that works perfectly.
This is working
<script type="text/javascript">
function checkPasswords() {
alert("test");
return false;
}
</script>
<h:commandButton id="login" value="Login" action="login"
onclick="checkPasswords();" type="submit"/>
Give s in lowercase in type="submit", The type attribute sets the type of button to create for this component. The valid values for this attribute are "submit" and "reset". The default value for this attribute is "submit".