Angular Form Validation ngMessages

Angular Form Validation ngMessages

Today, We want to share with you Angular Form Validation ngMessages.
In this post we will show you AngularJS Form Validation Example, hear for Introduction to AngularJs Form Validation we will give you demo and example for implement.
In this post, we will learn about Angular Validation with an example.

AngularJS simple offers client-side(Browser side) form validation.

AngularJS monitors all the state of the form (Browser side) and input fields Like as (input, textarea, select), and lets we notify the user click about the current static or dynamically state.

AngularJs is often seen(Browser side) as a viable solution all the for building full scale SPA – single page web-applications.

highlights all the HTML fields in error generated dynamically as we type

all the provide inline messages or properties while the user(Browser side) client-side is typing in a field

and form disable the submit button when all the form until all the needed data value right is available and the terms all the full – fill data and conditions checkbox is checked

READ :  Angular 6 CRUD Operations with PHP and MySQLi

AngularJS enriches all the HTML form filling and validation client-side(Browser side). We can use ng-click events to handle AngularJS (Browser side) events click on button press and use $dirty properties and $invalid properties flags to do the validations check in seemless way. Use novalidate bind in angular with a form declaration data to disable any browser like as a client-side specific validation. HTML Forms controls makes simple heavy or directive use of Angularjs execute all the events. Let’s have a easy way to quick look on events all and properties first.

# Angular Form Properties $valid, $invalid, $pristine, $dirty

Simple properties of Validate data using AngularJS

  • Angular Form Properties $dirty − simple states that all the value has been changed display.
  • Angular Form Properties $invalid − simple states that all the value entered display is invalid.
  • Angular Form Properties $error − simple states all the the exact display error.

Include Script

<a href="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js</a>
  
 var liveApp = angular.module("liveApp", []);  
 liveApp.controller('liveCtrl', function($scope) {  
	$scope.reset = function(){  
	   $scope.postName = "live24u";  
	   $scope.CatName = "admin";  
	   $scope.email = "[email protected]";  
	}  
	 $scope.reset();  
 });  
 

style

  
 table, th , td {  
	border: 2px solid green;  
	border-collapse: collapse;  
	padding: 10px;  
 }  

 

HTML Part

<h2>AngularJS Sample Application</h2>  
<div>  
   
 <form name="ProductForm">  
	<table border="0">  
	   <tr>  
		  <td>Enter Post Name:</td>  
		  <td>  
			 <span style="color:red">  
				<span>First Name is required.</span>  
			 </span>  
		  </td>  
	   </tr>  
		 
	   <tr>  
		  <td>Enter last name: </td>  
		  <td>  
			 <span style="color:red">  
				<span>Last Name is required.</span>  
			 </span>  
		  </td>  
	   </tr>  
		 
	   <tr>  
		  <td>Email: </td><td>  
			 <span style="color:red">  
				<span>Email is required.</span>  
				<span>Invalid email address.</span>  
			 </span>  
		  </td>  
	   </tr>  
		<tr>  
		  <td>  
			 <button>Reset</button>  
		  </td>  
		  <td>  
			 <button>Submit</button>  
		  </td>  
	   </tr>  
</table>  
 </form>  
</div>  

Full Example : Angular JS Forms – AngularJS Form Validation Example




    <title>Angular JS Forms - AngularJS Form Validation Example</title>
    <a href="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js</a>

    
        table,
        th,
        td {
            border: 2px solid green;
            border-collapse: collapse;
            padding: 10px;
        }
    





    <h2>AngularJS Sample Application</h2>
    <div>

        <form name="ProductForm">
            <table border="0">
                <tr>
                    <td>Enter Post Name:</td>
                    <td>
                        
                        <span style="color:red">  
                            <span>First Name is required.</span>
                        </span>
                    </td>
                </tr>

                <tr>
                    <td>Enter last name: </td>
                    <td>
                        
                        <span style="color:red">  
                            <span>Last Name is required.</span>
                        </span>
                    </td>
                </tr>

                <tr>
                    <td>Email: </td>
                    <td>
                        
                        <span style="color:red">  
                            <span>Email is required.</span>
                        <span>Invalid email address.</span>
                        </span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <button>Reset</button>
                    </td>
                    <td>
                        <button>Submit</button>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    
        var liveApp = angular.module("liveApp", []);
        liveApp.controller('liveCtrl', function($scope) {
            $scope.reset = function() {
                $scope.postName = "live24u";
                $scope.CatName = "admin";
                $scope.email = "[email protected]";
            }
            $scope.reset();
        });
    



AngularJS List of Events

AngularJS List of provides multiple events to angular form which can be associated with the HTML elements controls

  • AngularJS ng-click Events
  • AngularJS ng-dbl-click Events
  • AngularJS ng-mousedown Events
  • AngularJS ng-mouseup Events
  • AngularJS ng-mouseenter Events
  • AngularJS ng-mouseleave Events
  • AngularJS ng-mousemove Events
  • AngularJS ng-mouseover Events
  • AngularJS ng-keydown Events
  • AngularJS ng-keyup Events
  • AngularJS ng-keypress Events
  • AngularJS ng-change Events
READ :  PHP creating Object-Oriented CRUD System using PDO

We hope you get an idea about AngularJS Form Validation With ngMessages
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

Add a Comment

Your email address will not be published. Required fields are marked *