Share jquery plug-in--form validation
Jun 19, 2017 am 10:50 AMvar?regAction?=?(function?()?{ var?defaultOpts?=?{ 'regform'?:?'regfrom', 'username'?:?'username', 'userpwd'?:?'userpwd', 'confirmpwd'?:?'confirmpwd', 'checkcode'?:?'checkcode', 'accept'?:?'accept', 'errorTrips'?:?'errorTrips', 'channel'?:?'channel', 'loginAuto'?:?'loginAuto', 'btnAction'?:?'btnAction' }, isreg?=?1; //去掉空格 function?trim(str)?{ return?str.replace(//s+$|^/s+/g,?''); } //檢測(cè)email function?isEmail(email)?{ return?/^[/w/-/.]+@[/w/-/.]+(/./w+)+$/i.test(email) } //檢測(cè)用戶名 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('請(qǐng)輸入正確的郵箱地址').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('該郵箱已經(jīng)被注冊(cè)').css('visibility',?'visible'); optsObj.checkcode.hide(); $("#jChkcode").hide(); $("#jPrivacy").hide(); $("#jRemeberBox").show(); $("#repwd-box").hide(); $("#jhd").text("登錄快盤"); $("#jcnt").text("隨時(shí)隨地查看文件"); 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("注冊(cè)快盤"); $("#jcnt").text("只需5秒,立即擁有15GB空間"); optsObj.btnAction.val("立即注冊(cè)"); isreg?=?1; }); break; case?'2': default: errorTripsObj.css('visibility',?'hidden'); if?(callback)?{ callback(true); } } }?else?{ if?(callback)?{ callback(true); } } } }) } } //檢測(cè)密碼 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('請(qǐng)?zhí)顚懙卿浢艽a').css('visibility',?'visible'); userPwd.focus(); return?false; }?else?{ if?(len?< 6 || len >?32)?{ errorTripsObj.html('密碼應(yīng)在6-32位字符內(nèi)').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('請(qǐng)?zhí)顚懼貜?fù)登錄密碼').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(), 'rememberme'?:?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"?; } } } }); } } } } //檢測(cè)是否接受協(xié)議 function?checkAccpet()?{ var?optsObj?=?defaultOpts; var?acceptObj?=?optsObj.accept; var?errorTripsObj?=?optsObj.errorTrips; if?(acceptObj.attr('checked'))?{ return?true; }?else?{ errorTripsObj.html('請(qǐng)閱讀并接受用戶協(xié)議').css('visibility',?'visible'); acceptObj.focus(); return?false; } } //驗(yàn)證碼檢測(cè) function?checkCode()?{ var?optsObj?=?defaultOpts; var?checkcodeObj?=?optsObj.checkcode; var?errorTripsObj?=?optsObj.errorTrips; if?(checkcodeObj.length?==?1?&&?""?==?checkcodeObj.val())?{ errorTripsObj.html('請(qǐng)輸入驗(yàn)證碼').css('visibility',?'visible'); checkcodeObj.focus(); return?false; }?else?{ return?true; } } //注冊(cè)表單提交 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({'regform':'regform','username':'email','errorTrips':'erroInfo','userpwd':'pwd','confirmpwd':'re-pwd','accept':'chkaccpet','checkcode':'checkcode','loginAuto':'login-auto','btnAction':'jAction'});//初始化
The above is the detailed content of Share jquery plug-in--form validation. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Quark Netdisk and Baidu Netdisk are very convenient storage tools. Many users are asking whether these two softwares are interoperable? How to share Quark Netdisk to Baidu Netdisk? Let this site introduce to users in detail how to save Quark network disk files to Baidu network disk. How to save files from Quark Network Disk to Baidu Network Disk Method 1. If you want to know how to transfer files from Quark Network Disk to Baidu Network Disk, first download the files that need to be saved on Quark Network Disk, and then open the Baidu Network Disk client. , select the folder where the compressed file is to be saved, and double-click to open the folder. 2. After opening the folder, click "Upload" in the upper left corner of the window. 3. Find the compressed file that needs to be uploaded on your computer and click to select it.

1. After opening WeChat, click the search icon, enter WeChat team, and click the service below to enter. 2. After entering, click the self-service tool option in the lower left corner. 3. After clicking, in the options above, click the option of unblocking/appealing for auxiliary verification.

When users use the Edge browser, they may add some plug-ins to meet more of their needs. But when adding a plug-in, it shows that this plug-in is not supported. How to solve this problem? Today, the editor will share with you three solutions. Come and try it. Method 1: Try using another browser. Method 2: The Flash Player on the browser may be out of date or missing, causing the plug-in to be unsupported. You can download the latest version from the official website. Method 3: Press the "Ctrl+Shift+Delete" keys at the same time. Click "Clear Data" and reopen the browser.

What is the Chrome plug-in extension installation directory? Under normal circumstances, the default installation directory of Chrome plug-in extensions is as follows: 1. The default installation directory location of chrome plug-ins in windowsxp: C:\DocumentsandSettings\username\LocalSettings\ApplicationData\Google\Chrome\UserData\Default\Extensions2. chrome in windows7 The default installation directory location of the plug-in: C:\Users\username\AppData\Local\Google\Chrome\User

1. First, we enter NetEase Cloud Music, and then click on the software homepage interface to enter the song playback interface. 2. Then in the song playback interface, find the sharing function button in the upper right corner, as shown in the red box in the figure below, click to select the sharing channel; in the sharing channel, click the "Share to" option at the bottom, and then select the first "WeChat Moments" allows you to share content to WeChat Moments.

Recently, Baidu Netdisk Android client has ushered in a new version 8.0.0. This version not only brings many changes, but also adds many practical functions. Among them, the most eye-catching is the enhancement of the folder sharing function. Now, users can easily invite friends to join and share important files in work and life, achieving more convenient collaboration and sharing. So how do you share the files you need to share with your friends? Below, the editor of this site will give you a detailed introduction. I hope it can help you! 1) Open Baidu Cloud APP, first click to select the relevant folder on the homepage, and then click the [...] icon in the upper right corner of the interface; (as shown below) 2) Then click [+] in the "Shared Members" column 】, and finally check all

Steam is a platform used by game enthusiasts. You can buy and purchase many games here. However, recently many users have been stuck in the mobile token verification interface when logging into Steam and cannot log in successfully. Faced with this Most users don't know how to solve this situation. It doesn't matter. Today's software tutorial is here to answer the questions for users. Friends in need can check out the operation methods. Steam mobile token error? Solution 1: For software problems, first find the steam software settings on the mobile phone, request assistance page, and confirm that the network using the device is running normally, click OK again, click Send SMS, you can receive the verification code on the mobile phone page, and you are done. Verify, resolve when processing a request

PHP8 is the latest version of PHP, bringing more convenience and functionality to programmers. This version has a special focus on security and performance, and one of the noteworthy new features is the addition of verification and signing capabilities. In this article, we'll take a closer look at these new features and their uses. Verification and signing are very important security concepts in computer science. They are often used to ensure that the data transmitted is complete and authentic. Verification and signatures become even more important when dealing with online transactions and sensitive information because if someone is able to tamper with the data, it could potentially
