Simple Validations using Angular Example

Today, We want to share with you Simple Validations using Angular Example.In this post we will show you Angularjs input validations example, hear for Angularjs custom input validations example we will give you demo and example for implement.In this post, we will learn about angularjs form validation in controller with an example.

Simple Validations using Angular Example

There are the Following The simple About Angularjs form validations Full Information With Example and source code.

As I will cover this Post with live Working example to develop Angularjs input controls / fields example, so the angularjs form validation on button click is used for this example is following below.

AngularJS Validations Example

Angular is a platform for building mobile & desktop web Based user friendly and light weight applications.Angular,It’s TypeScript-based open-source Angularjs web application framework.

index.html

<!DOCTYPE html>
<html>
<head>
<title>
AngularJs Form Input Fields Validations Example AngularJS Tutorials, Demo with Example - Pakainfo.com</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script>
var webApplication = angular.module('formRootApplication', []);
webApplication.controller('formController', function ($scope) {
 
$scope.sendForm = function () {
$scope.message='Form Submited Successfully';
};
 
$scope.getClass = function (color) {
return color.toString();
}
});
</script>
<style>
.valid.false {
background: red;
}
.valid.true {
background: green;
}
.error {
color: red;
}
</style>
</head>
<body ng-app="formRootApplication" ng-controller="formController">
<h3>AngularJS Form Input Fields Validation</h3>
<form name="memberForm" ng-submit="sendForm()">
<label for="name">Name</label>
<input id="name" name="name" type="text" ng-model="member.name" required />
<span class="error" ng-show="memberForm.name.$error.required"> Required! </span>
<hr /><hr />
<label for="adress">Adress</label>
<input id="address" name="address" type="text" ng-model="member.address" required />
<span class="error" ng-show="memberForm.address.$error.required"> Required! </span>
<hr /><hr />
<label for="contact">Contact No</label>
<input id="mobile" name="mobile" type="number" ng-model="member.mobile" required />
<span class="error" ng-show="memberForm.mobile.$error.required">Required number!</span>
<span class="error" ng-show="memberForm.mobile.$error.mobile">Invalid mobile!</span>
<hr /><hr />
<label for="email">Email</label>
<input id="email" name="email" type="email" ng-model="member.email" required />
<span class="error" ng-show="memberForm.email.$error.required">Required!</span>
<span class="error" ng-show="memberForm.email.$error.email">Invalid Email!</span>
<hr /><hr />
<input type="checkbox" ng-model="terms" name="terms" id="terms" required />
<label for="terms">I Agree to the terms.</label>
<span class="error" ng-show="memberForm.terms.$error.required">You must agree to the terms</span>
<hr /><hr />
<button type="submit">Submit Form</button>
<hr /><hr />
<span>{{message}}</span>
</form>
</body>
</html>

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about angularjs form validation on submit.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.