Validating User Input on a Form in Angular JS

I have often seen entry level developers struggling with user input validation in AngularJS single page applications. In this post, I will give a quick but useful introduction of validations in AngularJS; consider this post as a base learning document from which you can do further learning.

Let’s start with an example as shown in the image below. You have a registration form with three fields with the following restrictions.

  1. Name : Required
  2. Email : Required and type Email
  3. Password : Required , type password and minimum length 6

We want to validate the rules mentioned above at the client side. There are two ways client side validation can be done in an AngularJS based single page application:

  1. Using the HTML5 validations
  2. Using the AngularJS validation directives
  3. A Combination of both

HTML5 validation

Here we’ve created the Add user form shown above using the mark up listed below:

image

Read full article on the Infragistics blog

2 responses to “Validating User Input on a Form in Angular JS”

  1. […] Validating User Input on a Form in Angular JS and How to work with the Ignite UI Chart in an AngularJS application and How to Enable CORS in the ASP.NET Web API (Dhananjay Kumar) […]

  2. Hi DJ,

    Finally Learning Angular JS from you through your blog. Proud of you and lots of love and respect.

Leave a comment

Create a website or blog at WordPress.com