Science, asked by Babupatel3317, 1 year ago

How are validations implemented in AngularJS?

Answers

Answered by keshrishi9898
0

<!DOCTYPE html>

<html>

<head>

   <script src="~/Scripts/angular.js"></script>

</head>

<body ng-app >

   <form name="studentForm" novalidate>

       <label for="firstName">First Name: </label> <br />

           <input type="text" name="firstName" ng-model="student.firstName" ng-required="true" />  

           <span ng-show="studentForm.firstName.$touched && studentForm.firstName.$error.required">First name is required.</span><br /><br />

           <label for="lastName">Last Name</label><br />

           <input type="text" name="lastName" ng-minlength="3" ng-maxlength="10" ng-model="student.lastName" />  

           <span ng-show="studentForm.lastName.$touched && studentForm.lastName.$error.minlength">min 3 chars.</span>

           <span ng-show="studentForm.lastName.$touched && studentForm.lastName.$error.maxlength">Max 10 chars.</span><br /><br />

           <label for="dob">Email</label><br />

           <input type="email" id="email" ng-model="student.email" name="email" />  

           <span ng-show="studentForm.email.$touched && studentForm.email.$error.email">Please enter valid email id.</span><br /><br />

       <input type="submit" value="Submit" />

   </form>

</body>

</html>


Anonymous: are you sure?
keshrishi9898: Yeah
Similar questions