zoukankan      html  css  js  c++  java
  • 当页面信息填写不完整,点击提交后,直接跳转到未填写位置

    <li>
      <span><em>*</em>联系人邮箱</span>
      <input class="input_mail input" name="email[]" required id="cyf_input_mail" type="text" placeholder="邮箱" />
      <u class="spa spa14"></u>
    </li>

    <input class="input2" type="button" id="submit1"  value="提交" />
    /**失焦提示**/
    $(function(){
      $(".input").blur(function(){
        $(".spa").css("color","#ff0000")
        if($(this).is("#cyf_input_mail")){
             var cyf_input_mail=$("#cyf_input_mail").val();
              var reg = /^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/;
              if(cyf_input_mail == undefined || cyf_input_mail == "") {
                $(".spa11").text("请填写联系人邮箱");
            $(this).css("border","1px solid #ff0000")
              }else if(!reg.test(cyf_input_mail)){
                  $(".spa11").text("请填写真实有效的邮箱地址");
              }else{
                  $(".spa11").text("");
                  $(this).css("border","1px solid #dbdbdb")
              }
           }
      })
    })
    /**聚焦提示**/
    $(".input").focus(function(){
      if($(this).is("#cyf_input_mail")){
        $(".spa11").text("请填写真实有效的常用邮箱地址").css("color","#aaa")
          $(this).css("border","1px solid #aaa")
       }
    })
    /**提交判断**/
    function checked(){
      reg = /^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/;
       if($("#cyf_input_mail").val()==""){
         $(".spa14").text('请填写联系人邮箱');
          $("#cyf_input_mail").focus();
          $(".spa").css("color","#ff0000");
          return false;
       }else if(!reg.test($("#cyf_input_mail").val())){
         $(".spa14").text("请填写真实有效的邮箱地址");
          $("#cyf_input_mail").focus();
          $(".spa").css("color","#ff0000");
          return false;
        } else{
           $(".spa14").text('');
        }
        return true;
    }
    $("#submit1").click(function(){
      $(".spa").css("color","#ff0000");
       $(".input").css("border","1px solid ff0000");
        if(checked()){
          $("#cyf_form").submit();
        }
    })
  • 相关阅读:
    OnEraseBkgnd、OnPaint与画面重绘
    .编译ADO类DLL时报错的解决方案
    VC列表框样式
    Codeforces 131D. Subway 寻找环树的最短路径
    Codeforces 103B. Cthulhu 寻找奈亚子
    Codeforces 246D. Colorful Graph
    Codeforces 278C. Learning Languages 图的遍历
    Codeforces 217A. Ice Skating 搜索
    Codeforces 107A. Dorm Water Supply 搜图
    Codeforces 263 D. Cycle in Graph 环
  • 原文地址:https://www.cnblogs.com/zhangjianzhen/p/9844980.html
Copyright © 2011-2022 走看看