Home
Tutorials
Microsoft Technologies Tutorials
Java Programming Tutorials
Web Designing Tutorials
Script Programming Tutorials
Database Programming Tutorials
Mobile Technologies Tutorials
Other Programming Tutorials
Examples
Articles
Tools
News
AngularJS Form Validations Example
Keywords : Angularjs form validations on submit example, Angularjs form validations in controller example, Angularjs validate controls in form example, Angularjs validate form fields on submit example
Example
<!DOCTYPE html> <html> <head> <title> AngularJS Form Validations Example </title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script type="text/javascript"> var app = angular.module('formApp', []); app.controller('formCtrl', function ($scope) { $scope.sendForm = function () { $scope.msg = "Form Validated"; }; }); </script> </head> <body> <div ng-app="formApp" ng-controller="formCtrl"> <h2>AngularJS Form Validations Example</h2> <form name="personForm" ng-submit="sendForm()"> First Name:<input type="text" name="firstname" ng-model="person.fname" required /> <span ng-show="personForm.firstname.$error.required"> Required! </span> <br /><br /> Last Name:<input type="text" name="lastname" ng-model="person.lname" required /> <span ng-show="personForm.lastname.$error.required"> Required! </span> <br /><br /> <button type="submit">Submit Form</button><br /><br /> <span>{{msg}}</span> </form> </div> </body> </html>
Click Here to See Result
Result
Previous
Next