패스워드 입력값이 같으면 메세지 출력
페이지 정보
작성자
관리자
작성일
2008.02.11 14:21
4,596 조회
본문
<html>
<head>
<title></title>
<script>
function verifynotify(field1, field2, result_id, match_html, nomatch_html) {
this.field1 = field1;
this.field2 = field2;
this.result_id = result_id;
this.match_html = match_html;
this.nomatch_html = nomatch_html;
this.check = function() {
if (!this.result_id) { return false; }
if (!document.getElementById){ return false; }
r = document.getElementById(this.result_id);
if (!r){ return false; }
if (this.field1.value != "" && this.field1.value == this.field2.value) {
r.innerHTML = this.match_html;
} else {
r.innerHTML = this.nomatch_html;
}
}
}
function verifyInput() {
verify = new verifynotify();
verify.field1 = document.password_form.password1;
verify.field2 = document.password_form.password2;
verify.result_id = "password_result";
verify.match_html = "<span style=\"color:blue\">패스워드가 확인되었습니다.<\/span>";
verify.nomatch_html = "<span style=\"color:red\">패스워드를 정확하게 입력하세요.<\/span>";
// Update the result message
verify.check();
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
verifyInput();
});
</script>
</head>
<body>
<form name="password_form">
패스워드입력 : <input type="password" name="password1" onkeyup="verify.check()"><br>
패스워드확인 : <input type="password" name="password2" onkeyup="verify.check()"></br>
<p>
<div id="password_result"> </div>
</form>
</body>
</html>
<head>
<title></title>
<script>
function verifynotify(field1, field2, result_id, match_html, nomatch_html) {
this.field1 = field1;
this.field2 = field2;
this.result_id = result_id;
this.match_html = match_html;
this.nomatch_html = nomatch_html;
this.check = function() {
if (!this.result_id) { return false; }
if (!document.getElementById){ return false; }
r = document.getElementById(this.result_id);
if (!r){ return false; }
if (this.field1.value != "" && this.field1.value == this.field2.value) {
r.innerHTML = this.match_html;
} else {
r.innerHTML = this.nomatch_html;
}
}
}
function verifyInput() {
verify = new verifynotify();
verify.field1 = document.password_form.password1;
verify.field2 = document.password_form.password2;
verify.result_id = "password_result";
verify.match_html = "<span style=\"color:blue\">패스워드가 확인되었습니다.<\/span>";
verify.nomatch_html = "<span style=\"color:red\">패스워드를 정확하게 입력하세요.<\/span>";
// Update the result message
verify.check();
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
verifyInput();
});
</script>
</head>
<body>
<form name="password_form">
패스워드입력 : <input type="password" name="password1" onkeyup="verify.check()"><br>
패스워드확인 : <input type="password" name="password2" onkeyup="verify.check()"></br>
<p>
<div id="password_result"> </div>
</form>
</body>
</html>
댓글 0