Ng-Submit-5

 

Ng-Submit-5

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <style> .ng-invalid { border: 1px solid red; } </style> </head> <body ng-app="app"> <div ng-controller="ExampleController"> <div class="container"> <h3>Form</h3> <form style="border:none" name="register" ng-submit="save(this)" novalidate ng-class="{true:'submitted'}[submitted]"> <label>Name: <input type="text" class="form-control" ng-model="user.username" required></label> <br /> <label>Email: <input type="email" class="form-control" ng-model="user.email"></label><br /> <input class="btn btn-default" type="submit"> </form> </div> </div> <script> var app = angular.module("app", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.save = function ($this) { if ($this.register.$invalid) alert("Form is not valid!"); else return; }; }]); </script> </body> </html>
Output