Angularjs input verification Detailed and instance code _ANGULARJS

Source: Internet
Author: User
Tags html form

Angularjs Input Validation

Angularjs forms and controls can validate the data entered.

Input validation

In the previous chapters, you've learned about Angularjs forms and controls.

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.

Application code

<! DOCTYPE html>  

Run Result:

Validating instances

User name:

Mailbox:

Note: HTML Form Properties Novalidate is used to disable browser default validation.

Instance resolution

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.

Property Description
$dirty Form has fill in the record
$valid The contents of the field are legal
$invalid The field contents are illegal
$pristine The form does not fill in the record

The above is the ANGULARJS input verification data collation, follow-up continue to add, hope to help students learn.

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.