I am using a command button from JSF. I don\'t know why I can\'t call my javascript function. NO alert will show when I click the button.
<input type="button">
Otherwise, it should work - I have exactly the same piece of code in my current codebase that works perfectly.
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".
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"/>