SoFunction
Updated on 2025-03-01

Form Verification Plugin

This article has shared the specific code for form verification for your reference. The specific content is as follows

Note: After downloading, just copy and paste it in the new js file name.

Test code:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title></title>
 <style>
  table{
   width: 690px;
  }
  th{
   padding-left: 23%;
   padding-bottom: 20px;
  }
  td{
   width: 110px;
  }
  b{
   color: #f00;
  }
 </style>
</head>
<body>
<!--Form-->
 <div class="ctn">
  <form class="fm" method="post" onsubmit="return doTable()">
   <table align="center">
    <th class="perWl" align="left" colspan="2">Logistics service provider</th>
    <tr>
     <td class="txt" align="right" width="100">Login land name say:</td>
     <td class="wlIcon icon">
      <s></s>
      <input type="text" name="lgname" maxlength="20"/>
      <b>*</b>
      <span></span>
     </td>
    </tr>
    <tr>
     <td class="txt" align="right">dense code:</td>
     <td class="wlIcon icon">
      <s class="mm"></s>
      <input type="password" name="password" maxlength="18"/>
      <b>*</b>
      <span></span>
     </td>
    </tr>
    <tr>
     <td class="txt" align="right">Confirm recognize dense code:</td>
     <td class="wlIcon icon">
      <s class="mm"></s>
      <input type="password" name="repass" maxlength="18"/>
      <b>*</b>
      <span></span>
     </td>
    </tr>
    <tr>
     <td class="wlBtns" align="center" colspan="2">
      <s></s>
      <button type="submit">Note book</button>
      <button class="cancel" type="submit">Pick remove</button>
     </td>
    </tr>
   </table>
  </form>
 </div>
 <script src="js/jquery-1.11."></script>
 <script src="js/"></script>
 <script type="text/javascript">
  /*Form Verification*/
  var gets = true;//Whether to submit the form  $(function(){
   // Prompt message=========================================================   $("input[name=lgname]").focus(function(){
    if($(this).val() == ){
     $(this).val('');
    }
   }).blur(function(){
    if($(this).val() == ''){
     $(this).val();
    }
   });
   //When the input box loses focus, the method to be executed   $("input[name=lgname]").blur(function(){doLgname();});
   $("input[name=password]").blur(function(){doPassword();});
   $("input[name=repass]").blur(function(){doRepass();});
  });
  // Verification of login name======================================  function doLgname(){
   var t = $("input[name=lgname]");
   var span = ();
   if(/^\w{6,16}$/.test(())){
    ("Fill in correctly").css({color:"green",fontSize:"12px"});
    return true;
   }else{
    ("Contains numbers, letters, underscores, lengths between 6-16").css({color:"#ec4e4e",fontSize:"12px"});
    return false;
   }
  }
  // Password verification======================================  function doPassword(){
   var t = $("input[name=password]");
   var span = ();
   if(() == ''){
    ("Password cannot be empty").css({color:"#ec4e4e",fontSize:"12px"});
    return false;
   }else{
    ('');
    if(/.{15,}/.test(())){
     ("The password length is not legal");
     return false;
    }
    return true;
   }
  }
  // Verification of password confirmation======================================  function doRepass(){
   var t = $("input[name=repass]");
   var span = ();
   if(() == $("input[name=password]").val() && () != ''){
    ("Fill in correctly").css({color:"green",fontSize:"12px"});
    return true;
   }else{
    ("The password is inconsistent twice").css({color:"#ec4e4e",fontSize:"12px"});
    return false;
   }
  }
  // How to execute when data is submitted  function doTable(){
   var lg = doLgname();
   var pass = doPassword();
   var repass = doRepass();
   if(lg&&pass&&repass){
    return true;
   }else{
    return false;
   }
  }
 </script>
</body>
</html>

Form plugin:Download address

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.