사용자 이름과 암호가 일치하지 않으면 경고를 표시하지만 경고에 ok를 클릭하면 양식이 로그인됩니다. 피할 수있는 방법을 알려줄 수 있습니까? 감사합니다.알림을 표시 한 후 양식을 제출하지 않으려면 어떻게해야합니까?
<html>
<f:view>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h:form id="loginForm">
<h1><center>Login page</center> </h1>
<h:panelGrid columns="2">
<h:outputLabel value="UserName"></h:outputLabel>
<h:inputText id="name" value="#{user.name}"> </h:inputText>
<h:outputLabel value="Password"></h:outputLabel>
<h:inputSecret id="password" value="#{user.password}"></h:inputSecret>
</h:panelGrid>
<h:commandButton type="button" value="Login" action="logged" onclick="checkPassword(this.form)"></h:commandButton>
</h:form>
</body>
<script type="text/javascript">
<!--
function checkPassword(form) {
var passsword = form["loginForm:password"].value;
var username=form["loginForm:name"].value;
var confirmpassword ="welcome";
var confirmusername="admin";
if((passsword == confirmpassword)&&(username==confirmusername))
form.submit();
else
alert("Username and Password does not match");
}
-->
</script>
</f:view>
</html>