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();
        }
    })
  • 相关阅读:
    asp.net微信内置浏览器下Session失效
    iOS 开发之路(WKWebView内嵌HTML5之图片上传) 五
    移动Web开发(二)
    iOS 开发之路(使用WKWebView加载Html5) 四
    iOS 开发之路(AES/DES加密实现) 三
    移动Web开发(一)
    iOS 开发之路(登陆验证调用WebService)二
    iOS 开发之路(登陆页键盘遮挡输入框问题)一
    canvas绘画常用方法
    JavaScript函数定义方式
  • 原文地址:https://www.cnblogs.com/zhangjianzhen/p/9844980.html
Copyright © 2011-2022 走看看