源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

基于jQuery实现表单提交验证

  • 时间:2021-01-09 06:23 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:基于jQuery实现表单提交验证
html表单代码:
&&!/.+@.+\.[a-zA-Z]{2,4}$/.test(this.value))){                         var errorMsg = '请输入正确的E-mail地址';                         $parent.append('<span class="formtips onError">'+errorMsg+'</span>');                     }else{                         var okMsg = '输入正确';                         $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');                     }                 }             });             $("form :input").focus(function(){                 var $parent = $(this).parent();                 $parent.find(".formtips").remove();             });             $("#send").click(function(){                var $parent = $(this).parent().parent();                $parent.find(".formtips").remove();                $("form .required:input").trigger('blur');                var numError = $('form .onError').length;                if(numError){                   return false;                }             });             $("#res").click(function(){                 var $parent = $(this).parent().parent();                 $parent.find(".formtips").remove();             });         });
代码很简单,也很易懂,小伙伴们直接拿走用吧,这里就不详细说明了。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部