Sunday, April 12, 2015

Validations with Angular JS

In this post I will explain how to use basic form validations with Angular JS. This will continue with the code written in my previous post.
Add web api controller action like below.
Add studentEditInfoController.js file like below.
Add studentEditInfoView.html  file below.
In here, I have used novalidate attribute. This will disable browser based validations. Using an angular condition, I have enabled to add has-error bootstrap class dynamically. In FirstName filed I gave min length and add required form attribute. Also I have disabled Save button till all validations passes for the form .
Modify, app.js locations.
When there are validation errors, the form will look like,

No comments:

Post a Comment