FrmCompareValidator.aspx |
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title></title> </head> <body>
<form id="form1" runat="server">
<div>
비교<br /><br />
암호 :
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
<asp:CompareValidator ID="valPassword" runat="server" ControlToValidate="txtPassword" ControlToCompare="txtPasswordConfirm" Type="String" ErrorMessage="암호를 확인하세요."></asp:CompareValidator><br />
암호확인 :
<asp:TextBox ID="txtPasswordConfirm" runat="server"></asp:TextBox>
<br /><br />
<asp:LinkButton ID="btnLogin" runat="server">로그인</asp:LinkButton>
</div>
</form> </body> </html> |
결과화면 |
[그림32-1] |
FrmCompareValidator.htm |
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<title></title>
<script type="text/javascript">
function Ok() { if
(document.getElementById("txtPassword").value
!= document.getElementById("txtPasswordConfirm").value) { alert("암호가 틀립니다."); document.getElementById("txtPassword").select(); // 선택 } else
{ alert("유효성 검사 통과"); }
}
</script> </head> <body>
비교 <br />
암호 : <input type="text" id="txtPassword" name="txtPassword" /><br />
암호확인 : <input type="text" id="txtPasswordConfirm" name="txtPasswordConfirm" /><br />
<input type="button" value="확인" onclick="Ok();" /> </body> </html> |
결과화면 |
[그림32-2] |
'ASP.NET' 카테고리의 다른 글
34.C# ASP.NET - CustomValidator [ 유효성검사컨트롤 ] (0) | 2009.10.13 |
---|---|
33.C# ASP.NET - RegularExpressionValidator [ 유효성검사컨트롤 ] (0) | 2009.10.13 |
31.C# ASP.NET - RangeValidator [ 유효성검사컨트롤 ] (0) | 2009.10.13 |
30.C# ASP.NET - RequiredFieldValidator [ 유효성검사컨트롤 ] (0) | 2009.10.13 |
17.ASP.NET - 자료실 게시판(9) : Down.aspx (0) | 2009.10.12 |
Comments