Ng-Form-8

 

In this example we have a required URL field in the ng-form. If you leave this field empty or enter invalid url the button gets disable.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="controllerName"> <ng-form name="editForm" novalidate> URL:<input type="url" required ng-model="correctUrl" name="correctUrl" /><br /> <span style="color:red" ng-show="editForm.correctUrl.$error.url">This is not correct URL.</span> <br /> <input type="button" ng-disabled="!editForm.$valid" ng-click="click()" value="click" /> </ng-form> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.correctUrl = "https://learnit.visrosoftware.com"; $scope.incorrectUrl = "htttps://learnit.visrosoftware.com"; }]); </script> </body> </html>
Output