作为一名程序员,在解决工作中遇到问题之后,做一些总结是有必要的,既方便总结温习相关知识点,也为广大的程序员提供了一些工作经历,给予同行一面明鉴.
html部分:
<!DOCTYPE html> <html lang="en"> <head> <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> </head> <body> <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> </body> </html> 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"; ?>
以上内容是小编给大家介绍的jQuery formValidator表单验证相关知识,希望对大家有所帮助,同时感谢大家对脚本之家网站的支持。

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.


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

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment