This article describes how to add custom verification rules for queryvalidate to verify email addresses and zip codes. For more information, see add custom verification using jQuery: validate.
JQuery. validator. addMethod add custom verification rules
AddMethod: name, method, message
Simple Example: add a single verif
This article describes how to add custom verification rules for queryvalidate to verify email addresses and zip codes. For more information, see add custom verification using jQuery: validate.
JQuery. validator. addMethod add custom verification rules
AddMethod: name, method, message
Simple Example: add a single verif
entered email address // var emailreg1 =/^ \ w + ([-+.] \ w +) * @ ("@") \ w + ([-.] \ w + )*\. \ w + ([-.] \ w +) * $/; // This can also be var emailreg =/^ \ w + (-\ w +) | (\. \ w +) * \ @ ("@") [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $/; if (emailreg. test (emailvalue )){}
ID card:
Var userCardvalue = $ ("# UserIDCard "). val (); // obtain the input ID card var userCardreg =/(^ \ d {15}
Today, I sorted out the url regular example of the url and the email address, and summarized the usage of jquery and js. There is no difference between others. I hope you can help me with this tutorial.
A friend asked me this question today, so I plan to share it with you.
In fact, the implementation is very simple, because the regular expression rules are the same and can be used in PHP, so it can also be
Hide or Show text when input box gets and loses focus let's take a look at the effect chart first.
Enter the default state of the box:
The input box gets the focus state:
You can see the search input box of the effect chart, the default display "username/email" prompts, when this
Copy codeThe Code is as follows:/*** Power by wooshoo copyright 2008-2009* Program name: JQuery dedicated input checker* Content: Checks user input of input [text password hidden] And textarea.* The check scope includes: number of characters, whether it contains special characters, whether it is an integer, whether it
In the second edition of the book 3.2.101, the introduction of the Val () method, the sample code used is common, and the example of the scene mode in the actual work will be used, so try to optimize a bit, write an HTML text input box to get with the loss of input focus of the prompt information display switch function.Original Book Code:DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "Http://
Copy Code code as follows:
/**
* Power by Wooshoo Copyright 2008-2009
* Program Name: JQuery Special Input Checker
* Content: specifically for input[text password hidden] and textarea user input to check
* The scope of the check includes: number of characters, whether it contains special characters, whether it
This article mainly introduces the usage of the text input auto-completion function in the jQueryUI library, and focuses on the use of the suffix auto-completion function when entering common email addresses, for more information, see autocomplete. It is a UI tool that can reduce user input. Generally
Enter the email a
Auto-complement (AutoComplete) is a UI tool that reduces user input to complete information. Generally inEnter the mailbox, search for keywords, and then extract the appropriate full string for the user to select.
A Call AutoComplete () method
$ (' #email '). AutoComplete ({
Source: [' aaa@163.com ', ' bbb@163.com ', ' ccc@163.com '],
});
Two Modify the AutoComplete () stylebecause
Based on the jquery input box drop-down hint layer, convenient for users to enter the mailbox prompt information, the need for friends can refer to the next//JavaScript Document(function($) {$.fn.extend ({"Changetips":function(value) {Value=$.extend ({divtip:""},value)var$ This= $( This); varINDEXLI = 0; //Click Document to hide the drop-down layer$ (document). Click (function(event) {if($ (event.target). a
regMail = new RegExp (tex. substring (tex. indexOf ("@"); // There is a string after "@". Note that the regular literal method cannot use variables. So here we use the new method.// Display the prompt layer and traverse the LI in itIf ($ this. val () = ""){Blus ();} Else {$ (Value. divTip ).Show ().Children ().Each (function (index ){Var valAttr = $ (this). attr ("email ");If (index = 1) {$ (this). text (tex). addClass ("active"). siblings (). remove
= "";//The string containing the "@"
var af =/@/;
var regmail = new RegExp (tex.substring (Tex.indexof ("@"));//A string after "@", note that the literal method is not variable. So here's the new way.
Let the hint layer show and traverse the inside of the Li
if ($this. val () = "") {
Blus ();
}else{
$ (value.divtip).
Show ().
Children ().
Each (function (index) {
var valattr = $ (this). attr ("email");
if (index==1) {$ (this). Text (Tex).
The Jquery Easyui is a very good UI framework, but there is no most common validation in form validation for the equality of values in the two output boxes, so I did an extension.
$.extend ($.fn.validatebox.defaults.rules, {/
* must be equal to a field/*
Equalto: {
validator:function (Value,param) {return
$ (param[0]). val () = = value;
}, Message
: ' Field mismatch '
}
};
Use examples:
P
The input box hides or displays text when it Gets or loses focus, so the focus effect is that many friends have seen it when filling out form forms, this article uses jquery to achieve the following, interested friends can refer to haEveryone can look at the search input box, the default display "user name/email" promp
Checks user input of input [textpasswordhidden] And textarea.
The Code is as follows:
/*** Power by wooshoo copyright 2008-2009* Program name: JQuery dedicated input checker* Content: Checks user input of input [text password hi
Remember last year to do a project, use the mailbox input automatic prompting function, so the internet search a bit, found that this write well, now in retrospect, reprinted, easy to access.
The wide use of the mailbox benefits from its free, so many sites in the registration will be directly using the mailbox as the account name
In order to improve the user experience, many websites will implement the automatic prompting function of the mailbox
Hide or show the text when the input box gets or loses the focus.Input box default status:Enter the box to get the focus status:You can see that the search input box displays the "user name/Email" prompt by default. When the input box gets the focus, it is automatically cleared and waiting for user
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.