AngularJS Form Validation

AngularJS Form Validation

In this Post We Will Explain About is AngularJS Form Validation With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to angularjs form validation on submitExample

In this post we will show you Best way to implement AngularJS Form Validation With ngMessages, hear for Easy Form Validation in AngularJS with ngMessageswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

AngularJS provides simple client-side HTMLform validation. It checks the some state of the HTML form and DOM input fields ( Like as a input, textarea box, select box), and lets We notify the all the user about the current state means errors.

Also Read :   PHP Stripe API ACH Payments using stripe.js

It also holds the some information about whether the HTML input fields have been some touched, or all the data modified, or not.

There are the Following directives are used to track some errors in an AngularJS HTML form:

1> $dirty – angular states that some value has been changed.
2> $invalid – angular states that some value entered is invalid.
3> $error – angular states the some exact error.

Code : AngularJS Form Validation Example


<!DOCTYPE html>  
      <title>Step By step Angular JS Forms</title>  
      <script src = ""></script>  
	//Devloped By
         table, th , td {  
            border: 1px solid grey;  
            border-collapse: collapse;  
            padding: 5px;  
     //Devloped By      
         table tr:nth-child(odd) {  
            background-color: lightpink;  
      //Devloped By     
         table tr:nth-child(even) {  
            background-color: lightyellow;  
      <h2>Live AngularJS Sample Application</h2>  
      <div ng-app = "liveApp" ng-controller = "EmpCtrl">  
         <form name = "empForm" novalidate>  
            <table border = "0">  
                  <td>Enter first name:</td>  
                  <td><input name = "fname" type = "text" ng-model = "fname" required>  
                     <span style = "color:red" ng-show = "empForm.fname.$dirty && empForm.fname.$invalid">  
                        <span ng-show = "empForm.fname.$error.required">Your First Name is required.</span>  
                  <td>Enter last name: </td>  
                  <td><input name = "lname"  type = "text" ng-model = "lname" required>  
                     <span style = "color:red" ng-show = "empForm.lname.$dirty && empForm.lname.$invalid">  
                        <span ng-show = "empForm.lname.$error.required">Your Last Name is required.</span>  
                  <td>Email: </td><td><input name = "email" type = "email" ng-model = "email" length = "100" required>  
                     <span style = "color:red" ng-show = "$dirty &&$invalid">  
                        <span ng-show = "$error.required">Your Email is required.</span>  
                        <span ng-show = "$">Your Invalid email address.</span>  
                     <button ng-click = "dataReset()">Reset</button>  
                     <button ng-disabled = "empForm.fname.$dirty &&  
                        empForm.fname.$invalid || empForm.lname.$dirty &&  
                        empForm.lname.$invalid ||$dirty &&  
              $invalid" ng-click="submit()">Submit</button>  
         var liveApp = angular.module("liveApp", []);  
         liveApp.controller('EmpCtrl', function($scope) {  
            $scope.dataReset = function(){  
               $scope.fname = "DSP";  
               $scope.lname = "Patel";  
               $ = "";  

Also Read :   Php Nested Loops - while foreach do-while continue break statement


I hope you have Got What is AngularJS Form Validation And how it works.I would Like to have FeadBack From My Blog( readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article( Are Most Always Welcome.