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();
        }
    })
  • 相关阅读:
    C#快速随机按行读取大型文本文件
    OpenReadWithHttps
    fiddler不能监听 localhost和 127.0.0.1的问题 .
    C#放缩、截取、合并图片并生成高质量新图的类
    JS判断只能是数字和小数点
    HTML5 Support In Visual Studio 2010
    GridView 获取列字段的几种途径
    微信朋友圈如何同时分享(图片+文字) Android版
    【Android】 PopupWindow使用小结
    Android 第三方应用接入微信平台(2)
  • 原文地址:https://www.cnblogs.com/zhangjianzhen/p/9844980.html
Copyright © 2011-2022 走看看