jQuery formValidator表单验证
html部分:
<code class="language-html"> <meta charset="UTF-8"> <title>formValidator</title> <script src="js/jquery-1.11.1.js"></script> <script src="js/formValidator-4.0.1.min.js"></script> <script src="js/DateTimeMask.js"></script> <script src="js/formValidatorRegex.js"></script> <link rel="stylesheet" href="css/validator.css"> <style> form{ width: 500px; margin: 100px auto; } table tr td:first-child{ text-align: right; } table tr td{ padding: 5px 0; } div{ margin-left: 10px; padding: 0 10px; } </style> <form name="myfm" id="myfm" action="1.html"> <table> <tbody> <tr> <td><label for="uname">用户名:</label></td> <td><input type="text" id="uname" name="uname"></td> <td><div id="unameTip"></div></td> </tr> <tr> <td><label for="pwd">密码:</label></td> <td><input type="password" id="pwd" name="pwd"></td> <td><div id="pwdTip"></div></td> </tr> <tr> <td><label for="repwd">重复密码:</label></td> <td><input type="password" name="repwd" id="repwd"></td> <td><div id="repwdTip"></div></td> </tr> <tr> <td><label>性别:</label></td> <td> <input type="radio" name="sex" value="male" id="male"> <label for="male">男</label> <input type="radio" name="sex" value="female" id="female"> <label for="female">女</label> </td> </tr> <tr> <td><label for="area">地区:</label></td> <td> <select name="area" id="area"> <option value="0">- 请选择 -</option> <option value="1">锦江区</option> <option value="2">金牛区</option> <option value="3">龙泉驿区</option> <option value="4">青羊区</option> </select> </td> </tr> <tr> <td><label for="num">身份证:</label></td> <td><input type="text" id="num" name="num"></td> <td><div id="numTip"></div></td> </tr> <tr> <td><label for="phone">电话号码:</label></td> <td><input type="text" name="phone" id="phone"></td> <td><div id="phoneTip"></div></td> </tr> <tr> <td><label for="email">邮箱:</label></td> <td><input type="text" name="email" id="email"></td> <td><div id="emailTip"></div></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" id="submit" value="提交"></td> <td></td> </tr> </tbody> </table> </form> <script> $.formValidator.initConfig({ //用于配置当前formValidator插件 formID: "myfm", debug: false, submitOnce: true, validatorGroup: '1', //设置验证组,默认值为1 onSuccess: function() { //验证成功后的回调函数 }, onError: function() { //验证失败后的回调函数 } }); $('#uname').formValidator({ ValidatorGroup: '1', //验证组为1 onEmpty: '用户名不能为空', //提示用户名不能为空 onShow: "", onFocus: '用户名必须为1到12位的数字或字母', //表单元素获得焦点的时候提示应输入的格式 onCorrect: '用户名输入正确' //输入正确的提示 }).regexValidator({ regExp: '^[0-9a-zA-Z]{1,12}$', //验证表单输入的正则表达式 onError: '用户名格式有误,请从新输入' //输入错误的提示 }).ajaxValidator({ //验证输入的用户名是否已经存在 dataType: 'html', //请求数据的格式 async: true, //异步方式 url: 'test.php', success: function(data) { if (data == 'false') { return false; } else { return true; } }, onError: '该用户名已存在,请从新输入', onWait: '正在对用户名进行合法性校验,请稍候...' }); $('#pwd').formValidator({ ValidatorGroup: '1', onEmpty: '密码不能为空', onShow: "", onFocus: '密码必须为6位以上的字母或数字', onCorrect: '密码输入正确' }).regexValidator({ regExp: '[0-9a-zA-Z]{6,}', onError: '密码格式有误,请从新输入' }); $('#repwd').formValidator({ ValidatorGroup: '1', onEmpty: '密码不能为空', onShow: "", onFocus: '密码必须为6位以上的字母或数字', onCorrect: '密码输入正确' }).regexValidator({ regExp: '^[0-9a-zA-Z]{6,}$', onError: '密码格式不正确' }).compareValidator({ //比较两次输入内容是否符合下面给出的比较符号 desID: 'pwd', //相比较的表单元素的ID值 operateor: '=', //要比较的两个元素之间的关系 onError: '两次密码输入不一致,请从新输入' //不满足以上关系的时候的提示 }); $('#num').formValidator({ ValidatorGroup: '1', onEmpty: '身份证不能为空', onShow: '', onFocus: '请输入您的身份证号', onCorrect: '身份证格式正确' }).regexValidator({ regExp: '^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{4}$', //15位身份证号码的正则表达式/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/ onError: '身份证格式有误,请从新输入' }); $('#phone').formValidator({ ValidatorGroup: '1', onEmpty: '手机号码不能为空', onShow: '', onFocus: '请输入您的手机号码', onCorrect: '手机号码格式正确', }).regexValidator({ regExp: '^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$', onError: '手机号码格式有误,请从新输入' }); $('#email').formValidator({ ValidatorGroup: '1', onEmpty: '邮箱地址不能为空', onShow: '', onFocus: '请输入您的邮箱地址', onCorrect: '邮箱格式正确' }).regexValidator({ regExp: '^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$', onError: '邮箱格式有误,请从新输入' }); </script> </code>
php部分代码:
<code class="language-php"><?php header('Content-Type:html'); $name=array('Tom','ervin','Jhon'); $uname=$_REQUEST['uname']; $notexit='true'; for ($i=0; $i <3 ; $i++) { if ($uname==$name[$i]) { $notexit='false'; break; }else{ } } echo "$notexit"; ?></code>

Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

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)

Hot Topics

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.

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

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

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

Forms are an integral part of writing a website or application. Laravel, as a popular PHP framework, provides rich and powerful form classes, making form processing easier and more efficient. This article will introduce some tips on using Laravel form classes to help you improve development efficiency. The following explains in detail through specific code examples. Creating a form To create a form in Laravel, you first need to write the corresponding HTML form in the view. When working with forms, you can use Laravel

This article will explain in detail how PHP calculates the MD5 hash value of a string. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. Calculating the MD5 hash value of a string in PHP Introduction MD5 (Message Digest 5) is a popular cryptographic hash function used to generate fixed-length hash values, often used to protect data integrity, verify file integrity and Create a digital signature. This article will guide PHP developers on how to use built-in functions to calculate the MD5 hash value of a string. md5() function PHP provides the md5() function to calculate the MD5 hash value of a string. This function receives a string parameter and returns a 32-character hexadecimal hash value.
