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--validation error text to prompt{{这个中间是name对应的值}}
rulesOne or more rules (i
This cell phone number is the correct validation function can be said to be the latest support, which has a detailed description, no matter what the next increase in the number of sections we are very easy to modify a little bit.
JavaScript phone number Regular expression validation function
Copy Code code as follows:
IP and domain name
javascript| function
First, the Verification class1, digital verification within1.1 Integers1.2 Integers greater than 0 (validation of ID to be transmitted)1.3 Validation of negative integers1.4 integers cannot be larger than IMAX1.5 integers cannot be less than imin2, Time Class2.1 Short time, form (13:04:06)2.2 Short Date, form (2003-12-05)2.3 Long time, shaped
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]. elements [email]. value;
If (reg. test (address) = false ){
Alert ('invalid Email address ');
Ret
Setcustomvalidity () Method:Sets the Validationmessage property of the input element, which is used to customize the method of the error message.Note: When a custom prompt is set with setcustomvalidity, the validity.customerror becomes true, and checkvalidity () always returns false, resulting in the correct format of the re-entry, or Will prompt you to set the error message.Workaround: Use Obj.validity.patternMismatch to judge, if the input format is correct, will setcustomvalidity empty, so th
JavaScript form Programming: I. How to find form elements: 1.var Oform=document.getelementbyid ("Form1"); 2.var oform=document.forms[form1]//is searched by name; Two. Common features of form fields: Disabled: This property is used to indicate whether a form control is available; Form property: This property returns the form containing the field; Blur (): This method causes the form field to lose focus; Focus (): This method causes the form field to ge
The first step:To remove the JS validation from eclipse:Will Windows->preference->java script->validator->errors/warnings->Enable Javascript sematic Validation in front of the hook removed;Step Two:Right click Project--Properties--Builders remove JavaScript Validator front tickIf there is no
Check the following items:
1. The validation-config.xml, validation-framework.js, validation-confi.dtd these three files are copied to the root directory of the website, you can first create a directory such as JS storage. 2. In the validation-framework.js 21st line changed to "/webprojectname/JS/", a few diagonal l
Since upgrading from MyEclipse to 7.0, project build is always slow, showing validating those js,html files. No matter how I adjust Windows > Preference > MyEclipse > Validation or manage validation, it's useless.My company's computer is Core2 Duo CPU T7250 @ 2.00GHz CPU, every time the machine is very slow validatingI created a new project and added a Web capabilities to track the. projet file in this proc
In this process, the. projet file is tracked, and finally the build is discovered where the validation is defined. It seems that my project is based on ExtJS2.0.2 Web project, so I will prompt to open JavaScript capabilities, this feature opened, the benefits do not feel, it will add to the JS file validation.Remove the following section from the. project file, and the item build finally returns to normal.O
most complete and most accurate method:
The code is as follows
Copy Code
function Isnumber (onum){if (!onum) return false;var strp=/^d+ (. d+)? $/;if (!strp.test (Onum)) return false;try{if (parsefloat (onum)!=onum) return false;}catch (ex){return false;}return true;}
This JavaScript code is very concise, you can see.
The code is as follows
Copy Code
There is a more stupid
Form validation is a user experience optimization that detects invalid data and marks these errors for end users.
The following is a display of the browser's own validation features can also be viewed on the mobile side:
HTML section:
CSS section:
fieldset{border:0}
. MyForm. form-control{
Display:block;
padding:5px;
width:100%
}
. MyForm input:focus:invalid +. form-erro
For the latest download, visit http://ww2validator.dev.java.net
Webwork2 extended validator instructions
1. Download and decompress the file
2. Find jscud_wwvalidators_1 _??. Jar, modify the classpath or copy it to the corresponding path
3. Copy the checkform. js file to your project and then reference
There are two methods to reference
I: Reference checkform. js directly in your program (note that you need to modify the path)
II: Modify/reload the form-close.vm, reference or include checkform
JavaScript limits the input of only numbers, determines the value of Event.keycode, and limits it to only numbers, if not numbers, returns an error, and if it is a number, continue.
Let me first show you how to verify that JavaScript is a number another way, by using the following functions: function Isnumber (onum)
{
if (!onum) return false;
var strp=/^/d+ (/./d+) $/;
if (!strp.test (Onum)) return false;
t
Cases
Add the onsubmit attribute to the form or the Add OnClick property of the Submit button, the value is return check (), the check is a JavaScript function, the validation table is single, no call, even if the validation fails will be submitted. In the check function, the validation failure returns false and retur
The first step:To remove the JS validation from eclipse:Window->preference->java script->validator->errors/warnings->enable Javascript Sematic The hooks in front of the validation are removed;Step Two:Locate the project directory and remove the following sections from the. project file in the projects directory:AndStep Three:Copy the JS file, and then delete the
Projects that do not have project settings for new or new importsTo remove the JS validation from eclipse:Will Windows->preference->java script->validator->errors/warnings->Enable Javascript sematic Validation in front of the hook removed;For an existing project:Modify the. Project file:Locate the project directory and delete the following sections in the. projec
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.