Disable submit input if text input is invalid

Description

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><!--from w  w w.j av  a  2  s.co 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>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities