Common form validation directives (basic concepts) 1. Mandatory fields ValidationIf a form input is filled in, simply add the HTML5 tag to the input field element required:2. Minimum lengthTo verify that the text entered by the form is longer than a certain minimum value, use the directive ng-minleng= "{number}" on the
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
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 Jquery,bootstrap and B
One, form security
1. Htmlspecialchars () function
Converts a special character to an HTML entity. This means that HTML characters such as
Cross-site scripting attacks (Scripting): For non-aliasing with cascading style sheets (cascading style Sheets, CSS), the cross-station scripting attack is abbreviated to XSS. A malicious attacker inserts malicious
(strredirect==null)strredirect = "default.aspx";Response.Redirect (strredirect, true);}ElseResponse.Redirect ("Logon.aspx", true);} Ensure that the following code is added to the InitializeComponent method of the code generated by the Web Forms Designer.This.cmdLogin.ServerClick + = new System.EventHandler (This.cmdlogin_serverclick); Create a Default.aspx page This section creates a test page where the user is redirected after authentication. If users browse this page without first logging in
;formclass= "Form-horizontal"role= "form"Action=""Method= "POST">{% Csrf_token%}{{form.as_table}} - If you use this method, you will need to render the form to the template in the view, otherwise open the page does not see the input box - Divclass= "Form-group"> label for= "Name1"class= "Col-sm-2 Control-label">
, 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).
First, we increase the username checking meth
be completed, but the prerequisite is not to increase the workload of JSP, and to change the role of JSP assumed.
We keep doing regular things by hand, constantly writing JavaScript to validate form data, writing server-side data validation in action or elsewhere, or using smartupload to process file uploads, and compute complex upload paths and file names. In fact, these things can be done automatically,
Recommended reading: JavaScript form verification length
JavaScript Form validation-Submitting a form
JavaScript form Validation-uncovering the veil of the regular expression
JavaScript can be used to validate these input data
following new folder en, copy the resources/lang/en/validation.php file to the ZH directory, and modify:
"min" = = ["Numeric" = "The:attribute must is at least:min.", "file" = "The:attribute must be at Lea St:min kilobytes. "," string "=": attribute must contain at least: min character. "," array " =" The:attribute must has at least:min items. ",", " required" and "=" : attribute must be filled in. ",
Others can be translated by themselves. Submit an empty
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 JavaScript to implement such a function.What do we ver
Online Demo 1
Local Downloads
Original link: http://www.gbtags.com/gb/share/5749.htmRecently in the user login, registration, and User Center ... Then in the MU class network jquery.validate need place, according to their own needs to make the details of the changes, it is important to style it.The first time to publish these, not good to say don't mind, start. First of all:
$("#form"). Validate({
//Edit in this area
In the process of web development, we often need to fill out the form of the operation, we generally have to submit form information when the content of the form is verified , STRUTS2 provides us with a simple implementation interface, so that we can easily verify the form. The following is the most traditional way to
How to use jquery for simple form validation:jquery can be used to form validation, of course, there are more complex forms validation, here is not introduced, the following is a brief introduction of how to use jquery simple form verification, and then we can be modified to
JS validation function of the call method and note:
1. Set the form onsubmit= "return test ()", with 2.3.4.5.6.
7.| | With, or,! non
8. Frequently used events: Onblur loses focus, onchange loses focus and content changes, onfocus element gets focus, onreset triggers this event when the Reset property in the form is fired, when the OnSubmit
When verifying that there are many fields in the form, you may want to put HTML generation and validation logic into controller, on the page, perhaps:
Then, define the fields and validation in controller. Angular-formly is there for this need.
In controller, define each field in an array:
Vm.rent
, the need for a unique chant, this is the writing on the HTML, custom JS code is their own write, here also has a corresponding code, is written with instructions, Grace on the code
Angular.module (' myApp ', [])
. Directive (' Ensureunique ', [' $http ', function ($http) {return
{
require: ' Ngmodel ',
link:function (scope, ele, Attrs, c) {
scope. $watch (Attrs.ngmodel, function () {
$http ({
Method: ' POST ',
URL: '/api/check/' + attrs.ensu
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.