Angularjs Validation

Prev Tutorial Next Tutorial

Angularjs Validation

An AngularJS forms and input control can validate input data. It is 100% JavaScript so AngularJS are also use for client side validation.

Example of AngularJS for client side validation


<!DOCTYPE html>

<script src= ""></script>
<h2>Client side Validation Example</h2>

<form ng-app="" ng-controller="ajvalidater" 
name="myForm" novalidate>

<input type="text" name="user" ng-model="user" required>
<span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
<span ng-show="myForm.user.$error.required">Username is required.</span>

<input type="email" name="email" ng-model="email" required>
<span style="color:red" ng-show="$dirty &&$invalid">
<span ng-show="$error.required">Email is required.</span>
<span ng-show="$">Invalid email address.</span>

<input type="submit"
ng-disabled="myForm.user.$dirty && myForm.user.$invalid ||$dirty &&$invalid">


function ajvalidater($scope) {
    $scope.user = 'Harry Porter';
    $ = '';



Username is required.

Email is required. Invalid email address.

Note: The HTML form attribute novalidate is used to disable default browser validation.

Prev Tutorial Next Tutorial

Download Projects

Google Adsense Advertisements
Free Classified Site – Bedpage

Yahoo Advertisements