AngularJS Tutorial - Disable submit input if text input is invalid








The following code shows how to Disable submit input if text input is invalid.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--   w ww.ja v  a2s.  c  o m-->
<body>
  <form ng-app name="myForm">
    <label>Name</label>
    <input type="text" name="name" ng-model="form.name" required>
    <input type="submit" ng-disabled="myForm.name.$invalid">
</form>
</body>
</html>

The code above is rendered as follows: