Validation does not work in bootstrap html

I gave validation to validate the field, specifying the required one as

<div class="form-group"> <label for="inputEmail" class="col-lg-4 col-lg-offset-1 control-label">Email address</label> <div class="col-lg-4"> <input class="form-control" ng-model="$root.customerDetails.eMail" placeholder="Enter customer email" type="email" required focus value = "{{emailId}}"> </div> </div> 

and then I press the submit button, but the check does not work. I can go to the next page without email.

Is there any other way to do a check.

Can someone help me thanks

It should look like this:

enter image description here

+5
source share
1 answer

The check does not stop feeding automatically. In your submit function, you need to check if the forum is valid.

Like this:

 angular.module('app', []). controller('ctrl', function($scope) { $scope.submit = function() { console.log('submitted'); } }); 
 .validation { font-size: 80%; color: red; } 
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script> <div ng-app="app" ng-controller="ctrl"> <form name="myForm"> <input type="text" name="txt" ng-model="txt" required /><br /> <!--<div class="validation" ng-show="myForm.$submitted && myForm.txt.$invalid">Please fill out the field</div>--> <button ng-click="myForm.$valid && submit()">Submit</button><br /> Form is valid: {{myForm.$valid}} </form> </div> 
0
source

Source: https://habr.com/ru/post/1257918/


All Articles