패스워드 입력값이 같으면 메세지 출력

관리자 0 4,137
<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>

Comments

광고
페이스북에 공유 트위터에 공유 구글플러스에 공유 카카오스토리에 공유 네이버밴드에 공유