The examples in this article summarize the commonly used validation functions for JavaScript. Share to everyone for your reference. The specific summary is as follows:
First, String class validation
1. Length Limit
Copy Code code as follows:
2. Can only be Chinese characters
Copy Code code as follows:
3. "Can only be Engli
Fuchangxi's Regular:Copy CodeThe code is as follows:/^ ([0-9a-za-z\-_\.] +) @ ([0-9a-z]+\. [A-z] {2,3} (\. [A-z] {2})?) $/g The start must be one or more word characters or--plus @, then one or more word characters or--. Then the point is "." and a combination of word characters and--can have one or more combinations.Copy CodeThe code is as follows:I don't quite understand the specific rules of the mailbox. It's easier to feel the regular.Check out several types of mailbox @ prefixes1, Pure Di
directory
Validator list
Server Side validator
Client JavaScript validator
Desc
Parameter
Memo
Requiredstringvalidator
Jsrequiredstringvalidator
Required string validator
Trim
Javascript deal trim
Stringlengthfieldvalidator
Jsstringlengthfieldvalidator
String Length validator
Trim
Minlength
Maxlength
Learning from scratch _ JavaScript _ series (8) -- js series (2) (event trigger sequence, text reading, js compiling ajax, input validation, and down menu)
(20) event trigger sequence
If there are multiple scripts in the document (for example, automatically executed scripts), they are executed in a certain order (in the HTML document ):
① Execute first
The output is green, and the background color turns gr
the previous general verification method in three fields of year/year, respectively), only the maximum value of the date is legal check;4.2, date format verification (please note that this validation does not validate the validity of the date, and has not found a way to get the year date data from the format ^_^):Where the format only supports Y, M, D, H, M, s (other characters as non time characters)4.3. List verification:Verify that the list (check
① determine if a String conforms to a regular requirementPatt.test (String);② find a string that matches the regular substringPatt.exec (String);"Example" form submission:A. User name cannot be empty, only numbers and letters, 6-11-bitB.email cannot be empty and properly formattedDOCTYPE HTML>HTMLLang= "en">Head> MetaCharSet= "UTF-8"> title>Documenttitle> style>Table{width:400px;Height:400px;Border:0;Border-collapse:collapse;background:Orange; }TD{Border:1px solid Gray;cursor:Poi
Web page Special Effects Universal Verification function library (telephone, mailbox, mobile phone, number)This verification library is our commonly used telephone, mailbox, mobile phone, digital QQ, letters, Chinese, English and other validation functions.
/*@author: Slchen@exemple:var email= "slchen@xxxxx.com";Alert ($v. Isemail (email));*/var $v = (functio
What kind of method should be used to remind users? You certainly don't want to use the alert () Prompt boxAdd a Sqan tag after entering the field"Phone"Name="Phone" Type="Text"Size=" A"Onblur="Validatenonemptyfun (This,document.getelementbyid (' phone_help ')");/>"Phone_help" class="Help">functionValidate_length (Inputfiled,helptext) {//If the input field content is empty, alert within the span tag if(inputfiled.value.length==0) {if(helptext!=NULL) helptext.innerhtml="text box cannot be
Native JavaScript phone number verification, email verification, id verification. When used, pass in the string to be validated, return ture to represent conformance, return false code does not conform.Use:
document.getElementById ("Btnphone"). Onclick=function () {
alert (Validationhandler.isphone ( document.getElementById ("Phoneinput"). Value) ==true?
javascript| Form Validation | dynamic | function ' Please dump it for checkform_js.asp use
'*****************************************************************************
' Function name: Checkform_js (FRMNAME,ERRSTR)
' Function: Dynamically write JavaScript Form validation functions using ASP Checksubmit ()
' Use meth
-www."
+
"([0-9a-z][0-9a-z-]{0,61})?" [0-9a-z]\.] Level two domain name
+
[a-z]{2,6}]///the domain-. com or. Museum
+
"(: [0-9]{1,4}]?"//Port-: 80
+
"((/?)|" A slash isn ' t required if there is no file name
+
"(/[0-9a-z_!~* ' ().;?: @=+$,%#-]+) +/?" $";
var re = new RegExp (Strregex);
if (!re.test (Str_url))
This. Alertandrfalse (Alertstr, IDSTR);
}
/**
* Check to see if email
* @param {} str
* @param {} alertstr popup field content
It's classname, not class.
Note that JavaScript uses classname to access the class attribute because class is a reserved keyword, because in the future JavaScript might begin to support classes like Java.
When we discussed the style attribute, we had a problem with tricky details and browser differences, just as we experienced a stormy sea. The class and ID cha
JavaScript Form Validation Regular expression encyclopedia
Using regular expressions to determine whether the Arabic numerals are 0-9
Copy Code code as follows:
function Regisdigit (fdata)
{
var reg = new RegExp ("^[0-9]$");
Return (Reg.test (fdata));
}
Use this expression to get the length of the string
Copy Code code as follows:
function Regdatalength (fdata
Copy Code code as follows:
Http://
JavaScript Validation Form Encyclopedia
1. Length Limit
Copy Code code as follows:
2. Can only be Chinese characters
3. "Can only be English
Copy Code code as follows:
4. Only the numbers
Copy Code code as follows:
5. Only English characters and numbers
Copy Code code as foll
Recently need to verify the legitimacy of the ID card, real-name verification is not expected, but the original validation rules too simple, but simply verified the length of the ID card, now the business needs to strengthen the identity card verification rules, the Internet found a lot of information, but not to my mind, helpless had to write directly, Code or w
Verify IPfunction IsIP (ipstr) {var reg =/^ (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) \. ( \D{1,2}|1\D\D|2[0-4]\D|25[0-5]) \. (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) \. (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) $/g;return Ipstr.match (reg);}The regular verification of this URL is comprehensive, it verifies that the situation includes IP, domain name, FTP, level two domain name, the domain name of the file, domain name plus port! User name, etc. informationfunction Isurl (str_url) {var Strregex = ' ^ ((https|http|ftp|rts
Form form onsubmit= "return Checkform (This)" name= "form" >In the input tag inside the name corresponding (name password age (int) email) can be such as: class= "Inputgri" name= "email
c2> "/>JavaScript basic Form Validation
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.