Try testing the following form with valid and invalid email addresses.
Code uses javascript to match the users input with a regular expression.
Function Code:
Copy codeThe Code is as follows: function validate (form_id, email ){
Var reg =/^ ([A-Za-z0-9 _ \-\.]) + \ @ ([A-Za-z0-9 _ \-\.]) + \. ([A-Za-z] {2, 4}) $ /;
Var address = document. forms [form_id]. element
Try testing the following form with valid and invalid email addresses. The
Code uses JavaScript to match the users input with a regular expression.
Function code:
Copy Code code as follows:
function Validate (Form_id,email) {
var reg =/^ ([a-za-z0-9_\-\.]) +\@ ([a-za-z0-9_\-\.]) +\. ([a-za-z]{2,4}) $/;
var address = Document.forms[form_id].ele
When using the Javascrip regular expression, it is found that the contents of a particular string within a string can be taken according to a regular expression. To illustrate:functionCheck (email_address) {varRegex =/^ ([0-9a-za-z\-_\.] +) @ ([0-9a-z]+\. [A-z] {2,3} (\. [A-z] {2})?) $/G; if(Regex.test (email_address)) {varuser_name = Email_address.replace (Regex, "$" ); vardomain_name = Email_address.replace (Reg
The last article we use string lookup method to achieve the ASP email email address verification, there may be more like the regular expression of friends, here also give the corresponding code.Method One
Copy Code code as follows:
Public Function Chkmail (ByVal Email)
Dim Rep,pmail:chkmail = True:set Rep = New RegExp
Rep.pattern = "([. a-za-z0
string validator and a fungicide library. It can be used on both the client and the server side.Online preview3.valid.jsValid.js is a simple JavaScript library for data validation. The following is a validation function.? String:isstring, MinLength (min), maxLength (max), Length (min, max), Regex (REG)? Number:isnumbe
The most common verification is email address verification. Websites are common. Various web scripts also use regular expressions "(Regular Expression) Verify the email address we entered to determine whether the email address is valid. Some can also separate the username and domain name. Use nowJavascriptThe language implements
JavaScript can be used to validate these input data in an HTML form before the data is sent to the server.
The typical form data that is validated by JavaScript is:
• Has the user filled out the required items in the form?• Is the email address that the user entered legal?• Has the user entered a valid date?• Does the user enter text in the Data field (numeric
Recommended reading: JavaScript form verification length
JavaScript Form validation-Submitting a form
JavaScript form Validation-the first recognition of regular expressions
In the previous article to introduce JavaScript form
}$ the correct format is: Start with a letter, length between 6-18, can only contain characters, numbers and underscores.
Verify that it contains ^% ',; =?$\ ' and other characters:[^% ', =?$\x22]+
Verify Chinese characters: ^[\u4e00-\u9fa5],{0,}$
Verify email Address: ^\w+[-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$
Verify interneturl:^http://([\w-]+\.) +[\w-]+ (/[\w-./?%=]*) $ ^[a-za-z]+://(w+ (-w+) *) (. w+ (-w+) *) *) * (? s*)? $
Verify p
Data validation is an important step for network applications to accept data from the client, after all, you need to ensure that they conform to the expected format before using customer data. In Web applications, you can choose to use specific platform tools such as ASP.net, JSPs, and so on, or you can take advantage of client JavaScript, which can simplify data valida
With the advantage of client-side JavaScript, regular expressions in JavaScript can simplify the work of data validation, and below share with you how to use JavaScript and regular expressions for data validation, interested friends can refer to the next haData
JavaScript Regular verifies that the string is empty
Purpose: Check if the input string is empty or all are spaces
The input quantity is a string: str
Return: Returns True if the input amount is NULL or FALSE
function IsNull (str) {
if (str = "") return true;
var Regu = "^[]+$";
var re = new RegExp (regu);
return Re.test (str);
Regular expression Validation mailbox
Complete example of multiple email addresses verified by JS Regular Expressions [separated by semicolons] and JavaScript semicolons
This article describes how to verify multiple mailboxes using JS regular expressions. We will share this with you for your reference. The details are as follows:
PS: here we will provide two very convenient Regular Expression tools for your reference:
1. Lightweight JavaScript Form validationReferencing files in your app validator.min.jsInstance: for= "Email" > Email verification DescriptionNew Validator (formName, option, callback)FormNameformNameis the value in the id tag name , as in the aboveexample_formOption
namenamethe corresponding value in input
display--
JavaScript Validation form instance
If you are creating a responsive site that contains some input forms, you should verify user input data. If you have to verify the name, last name, Email, username, age, compression code, and other fields of a registry ticket, you do not need to send unnecessary responses to your server. Next you will learn how to use
Enable the unobtrusive JavaScript feature in ASP. The client-side validation JS code (combined with jquery.validate) can be automatically generated at run time by the server end based on the validation rules set in model. This solves the problem of the form validation one time code, two authentication (client + server
JavaScript form authentication Age
JavaScript form validation age, to determine whether an input is in line with age, implemented through regular expressions.
Check Age
function Isage (str) {
var mydate=new Date;
var now=mydate.getfullyear ();
if (str return false;
}
return true;
}
Regular expression Validation mailb
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.