700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 分享jquery插件–表单验证

分享jquery插件–表单验证

时间:2022-05-28 12:28:40

相关推荐

分享jquery插件–表单验证

web前端|js教程

jquery,验证,表单,插件,分享

web前端-js教程

盗号软件源码手机版,vscode+yii,ubuntu版本不同有什么区别,css 重启tomcat,sqlite3 back,QQ 第三方插件,前端框架使用率 ,爬虫下载微博视频,php5.6配置,seo蜘蛛论坛,地方门户网站推广,网页游戏倾城,个人网站介绍模板lzw

var regAction = (function () {var defaultOpts = { egform : egfrom,username : username,userpwd : userpwd,confirmpwd : confirmpwd,checkcode : checkcode,accept : accept,errorTrips : errorTrips,channel : channel,loginAuto : loginAuto,tnAction : tnAction},isreg = 1;//去掉空格function trim(str) {return str.replace(//s+$|^/s+/g, \);}//检测emailfunction isEmail(email) {return /^[/w/-/.]+@[/w/-/.]+(/./w+)+$/i.test(email)}//检测用户名function checkUserName(callback) {var optsObj = defaultOpts;var nameObj = optsObj.username;var errorTripsObj = optsObj.errorTrips;var value = trim(nameObj.val());nameObj.val(value);if (!isEmail(value)) {errorTripsObj.html(请输入正确的邮箱地址).css(visibility, visible);nameObj.focus();if (callback) {callback(false);}} else {$.ajax({url : /index.php?ac=account&op=checkuser,dataType : json,type : post,data : {username : value},success : function (res) {if (res) {switch (res.string) {case 1://errorTripsObj.html(该邮箱已经被注册).css(visibility, visible);optsObj.checkcode.hide();$("#jChkcode").hide();$("#jPrivacy").hide();$("#jRemeberBox").show();$("#repwd-box").hide();$("#jhd").text("登录快盘");$("#jcnt").text("随时随地查看文件");optsObj.btnAction.val("立即登录");isreg = 2;//nameObj.focus();if (callback) {//callback(false);callback(true);}nameObj.change(function () {optsObj.checkcode.show();$("#jChkcode").show();$("#jPrivacy").show();$("#jRemeberBox").hide();$("#repwd-box").show();$("#jhd").text("注册快盘");$("#jcnt").text("只需5秒,立即拥有15GB空间");optsObj.btnAction.val("立即注册");isreg = 1;});break;case 2:default:errorTripsObj.css(visibility, hidden);if (callback) {callback(true);}}} else {if (callback) {callback(true);}}}})}}//检测密码function checkPwd(callback) {var optsObj = defaultOpts;var userPwd = optsObj.userpwd;var username = optsObj.username;var confirmPwd = optsObj.confirmpwd;var errorTripsObj = optsObj.errorTrips;var loginAuto = optsObj.loginAuto;var len = trim(userPwd.val()).length;if (0 == len) {errorTripsObj.html(请填写登录密码).css(visibility, visible);userPwd.focus();return false;} else {if (len 32) {errorTripsObj.html(密码应在6-32位字符内).css(visibility, visible);userPwd.focus();return false;} else {errorTripsObj.css(visibility, hidden);if (isreg === 1) {var reLen = trim(confirmPwd.val()).length;if (0 == reLen) {errorTripsObj.html(请填写重复登录密码).css(visibility, visible);confirmPwd.focus();return false;} else {if (userPwd.val() != confirmPwd.val()) {errorTripsObj.html(两次密码输入不一致).css(visibility, visible);confirmPwd.focus();return false;} else {return true;}}} else {if (loginAuto.attr("checked") === "checked") {loginAuto.val("1");} else {loginAuto.val("0");}$.ajax({url : /index.php?ac=account&op=login,type : post,dataType : json,data : {username : username.val(),userpwd : userPwd.val(), ememberme : loginAuto.val(),isajax : yes},success : function (res) {if (res.state == 0) {errorTripsObj.html(用户名密码不匹配).css(visibility, visible);userPwd.focus();return false;} else {if(callback) {location.href = "/home.htm" ;}}}});}}}}//检测是否接受协议function checkAccpet() {var optsObj = defaultOpts;var acceptObj = optsObj.accept;var errorTripsObj = optsObj.errorTrips;if (acceptObj.attr(checked)) {return true;} else {errorTripsObj.html(请阅读并接受用户协议).css(visibility, visible);acceptObj.focus();return false;}}//验证码检测function checkCode() {var optsObj = defaultOpts;var checkcodeObj = optsObj.checkcode;var errorTripsObj = optsObj.errorTrips;if (checkcodeObj.length == 1 && "" == checkcodeObj.val()) {errorTripsObj.html(请输入验证码).css(visibility, visible);checkcodeObj.focus();return false;} else {return true;}}//注册表单提交function regFormSubmit(e, data) {checkUserName(function (f) {var result, checkPwdResult;if (isreg === 1) {defaultOpts.regform.attr("action", "/index.php?ac=account&op=registerhanlder");result = f && checkPwd() && checkAccpet() && checkCode();if (result) {defaultOpts.regform.unbind(submit).submit();}} else {checkPwd( f );}});if (!data) {return false;}}function bindEvent() {var optsObj = defaultOpts;optsObj.regform.submit($.proxy(regFormSubmit, this));optsObj.username.change(function () {checkUserName();})optsObj.userpwd.change($.proxy(checkPwd, this));if (isreg === 1) {optsObj.confirmpwd.change($.proxy(checkPwd, this));}}return {init : function (opts) {$.each(opts, function (i, n) {opts[i] = $("#" + n);});defaultOpts = $.extend(defaultOpts, opts);bindEvent();},checkEmailVlaue : function () {checkUserName();}};})();

regAction.init({ egform: egform,username:email,errorTrips:erroInfo,userpwd:pwd,confirmpwd: e-pwd,accept:chkaccpet,checkcode:checkcode,loginAuto:login-auto,tnAction:jAction});//初始化

vip视频解析源码,u启 ubuntu,tomcat嵌入静态页面,爬虫动漫头像,php多少钱一个月,马尾区专业seo服务费lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。