Angularjs forms and input validation instances _angularjs

Source: Internet
Author: User
Tags html form

Angularjs forms and controls can provide validation and warn you about illegal data entered by users.

Note: client-side validation does not ensure that user input data is secure, so data validation on the server is also required.

1, HTML control

The following HTML INPUT element is called an HTML control: an INPUT element, a SELECT element, a button element, a TEXTAREA element.

2. HTML form

The Angularjs form is a collection of input controls. HTML forms typically exist at the same time as HTML controls.

<! DOCTYPE html>  

3. Input verification

Angularjs forms and controls can provide validation and warn you about illegal data entered by users. Client-side validation does not ensure that user input data is secure, so data validation on the server is also required.

<! DOCTYPE html>  

The ANGULARJS ng-model directive is used to bind input elements into the model. The model object has two properties: User and email. We use the Ng-show directive, color:red is displayed when the message is $dirty or $invalid.

No input validation of the initial value: Note ng-app= "", Ng-app have a value must be connected to the code module, using the Angular.module function to create the module.

 <! DOCTYPE html>  

4. ng-disabled Example

<!doctype html>  

5. Ng-submit Example

 

6, maxlength and minlength examples

<! DOCTYPE html>  

7. Ng-class Example

<! DOCTYPE html>  

8. ng-if Example

<! DOCTYPE html>  

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.