jQuery를 사용하여 양식 비밀번호의 일관성을 확인하는 방법

php中世界最好的语言
풀어 주다: 2018-03-15 16:13:01
원래의
1331명이 탐색했습니다.

이번에는 jQuery를 사용하여 양식 비밀번호의 일관성을 확인하는 방법과 jQuery를 사용하여 양식 비밀번호의 일관성을 확인하는 데 어떤 주의 사항이 있는지 보여 드리겠습니다. 다음은 실제 사례입니다.

jQuery script

<script type="text/javascript">
function check_password() {
  if ($("#password").val() != $("#checkPWD").val()){
    alert("请保证两次输入密码的一致性!");
    $("#checkPWD").focus();
  }
}
function check_email() {
  var reg = /\w+[@]{1}\w+[.]\w+/;
  if (!reg.test($("#email").val())){
    alert("请输入正确的email!");
    $("#email").focus();
  }
}
function check_phone() {
  var reg = /^1[34578]\d{9}$/;
  if (!reg.test($("#phone").val())){
    alert("请输入正确的手机号!");
    $("#phone").focus();
  }
}
</script>
로그인 후 복사

html file

<!DOCTYPE html>
<html>
<head>
  <script src="jquery1.3.2.js"></script>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>注册界面</title>
</head>
<body>
  <center>
    <h1>用户注册</h1>
    <form action="" method="post">
      <table width="400px" cellspacing="0px" cellpadding="0px" border="1px">
        <tr>
          <td>用户名</td>
          <td><input type="text" name="username" placeholder="用户名为3-12位字母数字或下划线组合" ></td>
        </tr>
        <tr>
          <td>密 码</td>
          <td><input type="password" name="password" placeholder="密码长度为6-12位的纯数字" id="password"></td>
        </tr>
        <tr>
          <td>确认密码</td>
          <td><input type="password" name="checkPWD" placeholder="密码长度为6-12位的纯数字" id="checkPWD" onchange="check_password()"></td>
        </tr>
        <tr>
          <td>手机号码</td>
          <td><input type="text" name="phone" placeholder="请输入正确的手机号码格式" id="phone" onchange="check_phone()"></td>
        </tr>
        <tr>
          <td>邮箱</td>
          <td><input type="email" name="email" placeholder="请输入正确邮箱格式" id="email" onchange="check_email()" required="required"></td>
        </tr>
        <tr>
          <td colspan="2" style="text-align:center">
            <input type="submit" value="注册">
            <input type="reset" value="重置">
          </td>
        </tr>
      </table>
    </form>
  </center>
</body>
</html>
로그인 후 복사

실행 결과:

이 기사의 사례를 읽은 후 방법을 마스터했다고 믿습니다. 더 흥미로운 정보를 보려면 주의하세요. PHP 중국어 웹사이트의 다른 관련 기사를 확인하세요!

추천 자료:

빈 공간에서 숨겨진 요소를 찾는 방법

Ajax를 사용하여 드롭다운 상자를 새로 고치지 않고 연결하는 방법

jQuery가 로드되었는지 확인하는 방법

위 내용은 jQuery를 사용하여 양식 비밀번호의 일관성을 확인하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!