Jquery.validate.js using custom form validation rules, here are some common validation regulationsJquery.validate.js demo See the jquery validate powerful jquery form validation plugin
; Background-color: #dceaf2; padding:3px; Border:solid 1px #6dbde4; Visibility:hidden; line-height:20px;
";
$ ("Body"). Append ("
How to use:
1, referencing CSS and JS (must refer to jquery):
2, form HTML code (partial code):
3, the implementation of the Verification JS code:
Save Data
function Save () {
if (Simpovalidate.valid ()) {//perform
Series Catalog
Note: This section of reading needs to have the basis of MVC custom validation, otherwise it is more laborious
All along, the verification of the form is indispensable, Microsoft's things still do more humane, from WebForm to MVC, have done a two-way authentication
Using JS alone to achieve the front-end verification is extremely unsafe, so this time we look at MVC on the self-annotated veri
Today, let's talk about forms validation, some people say that we use regular to verify the form validation is very troublesome, and now let me introduce you to the form validation plug-in: Jquery.validate.min.jsIt is used in conjunction with
, and dynamically load the picture represents the check and the corresponding inspection results.
Figure 3 Registration Form
JQuery Validation PluginNow, we need to modify the form checking controls defined in the previous blog, and we need to increase the user name check and the text box lose Focus event (Blur).
to get a matching number, you had to use JQuery to help validate the input. HTML5 has added a number of types and added some additional attributes:
Min: Specifies the minimum input number that the input box can accept.
Max: You guessed right, which is the maximum number that is allowed to enter.
Step: Property input domain legal interval, default is 1.
Similarly, on smartphones, we get a keypad with only a few digits, which is
The use of jquery encapsulated JS file to form validation, improve the efficiency of web development. I have written an example of validation to show you.The validation methods included in the example are not exhaustive, assuming that no one wants to passBaidu Search key: jq
to the database.Run the application, browse the address /movies, and click on the "Create New" link to add a movie. If we have some illegal data in the input process, the client will display some errors, which are implemented by jQuery client authentication. When an error occurs, the text box is added with a red border and a description of the error message is displayed. These error messages can take effect on the client (using JavaScript and
There is such a scenario, we may have to do some validation when submitting form form, such as judgment is not empty, phone format verification, mailbox format verification, etc., handwriting is also available.But today I introduce a bootstrap plugin to simplify development. Is bootstrapvalidator.js.Directly on the handwriting code.1. First
Html code
Name
In this article, we will introduce jQuery Validation with the js snippets above.Verification starts with this method: validate ([options])I. options)[1] debug type: Boolean default: falseNote: Enable the debugging mode. If it is true, the form is not submitted, and some error messages (Firebug or Firebug lite is required) are displayed on the cons
First, prefaceIn the Web application, the data validation is very important, a careless to produce a bug, and more bugs appear to have a personal development ability, this time if you can have a handy verification plug-in, development efficiency will be greatly improved. As if ox Demon King told Sun Wukong, you lack a weapon, so he grabbed the stick, with that called a cool. Three the first Jiao told Zhanshenyangjiian, you lack a weapon in hand, so he
Preface:
Since 2017.7.6, it's been a full five months now. The training phase in Tianjin is nearing the end, and I think it is necessary to sum up the points that have been learned in this period of time. Do technology heavy in experience and accumulation, since into the software development of the "pit", I can only bite the bullet to go down. Anyway, on this "soft" road, every step I go through should have its meaning and value.
The front-end project is described: An automated data acquisition
This example describes the YII framework form model and validation usage. Share to everyone for your reference, specific as follows:
The form model Cformmodel most of the inherited Cmodelcmodel, because the table model data does not need to be persisted, so it is primarily on the validation operation. The following is
After using bootstrap, he was has-error by his own style, it would be more troublesome to use it, the usual use of jquery.validate words only use his own style, and there are models in the use of model validation more convenient point. How to solve it?
Of course, you can write a specific jquery plugin for this, I feel quite troublesome, like to write plug-ins under the study.
First NuGet gets an MVC edito
message, need to know the name of the specific error such as "requeired" These names can be found in the API class Meta: = vm '__all__'3. Edit views.pydefAdd (Request):ifRequest.method = ='POST': #Print request. post[' Hvname '],request. post[' HVIP '] PrintRequest.method Form=Hvform (Request. POST)ifForm.is_valid ():#determine if the input data is legitimate #Print
Copy CodeThe code is as follows:
Class Formmodel extends Model {Automatic Validation settings/** One: Automatic verificationThe definition of automatic validation is this: Array (field,rule,message,condition,type,when,params)Field: Represents the domain name of the database;Rule: The representative is the rules;Its value depends on the type;If condition is function (callback), rule is a function nameCond
=new RegExp (/^[0-9| a-z|_]{1,17}@[a-z|0-9]{1,5}. (COM|CN|NET|ORG|CC) $/);var Shuru=document.getelementbyid ("Youxiang"). Value; if (Yx.test (Shuru)) {Alert ("Zhengque");}Else{Alert ("Cuowu");}}3, the method of timing timingSetTimeout (); Execution code in the future--using recursive methodsCleartimeout (); cancel settimeout ();Third, the jquery library (emphasis)--is a JavaScript library.The main jquery fu
']);} } return $this->render (' Create ', [ ' model ' = $model,]);//@see Http://www.manks.top/yii2_modal_activeform_ ajax.html//See the primary validation action, which is an asynchronous validation when the form field loses focus, and if the form is submitted directly, the action is also performed to verify pub
selected element:?
1
$(selector).keyup()
To add a function to the KeyUp event:?
1
$(selector).keyup(function)
Iv. events triggered when a form is submittedExample: JQuery Submit () methodWhen the form is submitted, an alert box appears:?
123
$("
After the user fills out the form submits, the server-side script verifies the data first, guarantees the data correctness (for example, the data conforms to the request content, the format is correct, etc.) and then the data to the database storage for later use. You can also use JavaScript on the client computer to verify forms, faster, more efficient user operations. While there are many advantages to using JavaScript for forms
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.