Created
March 26, 2014 18:24
-
-
Save maltzsama/9789915 to your computer and use it in GitHub Desktop.
Validação para coisas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form name="signup_form" novalidate ng-submit="signupForm()"> | |
| <fieldset> | |
| <legend>Signup</legend> | |
| <div class="row"> | |
| <div class="large-12 columns"> | |
| <label>Your name</label> | |
| <input type="text" | |
| placeholder="Name" | |
| name="name" | |
| ng-model="signup.name" | |
| ng-minlength=3 | |
| ng-maxlength=20 required /> | |
| <div class="error-container" | |
| ng-show="signup_form.name.$dirty && signup_form.name.$invalid && signup_form.submitted"> | |
| <small class="error" | |
| ng-show="signup_form.name.$error.required"> | |
| Your name is required. | |
| </small> | |
| <small class="error" | |
| ng-show="signup_form.name.$error.minlength"> | |
| Your name is required to be at least 3 characters | |
| </small> | |
| <small class="error" | |
| ng-show="signup_form.name.$error.maxlength"> | |
| Your name cannot be longer than 20 characters | |
| </small> | |
| </div> | |
| </div> | |
| </div> | |
| <button type="submit" class="button radius">Submit</button> | |
| </fieldset> | |
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.controller('signupController', ['$scope', function($scope) { | |
| $scope.submitted = false; | |
| $scope.signupForm = function() { | |
| if ($scope.signup_form.$valid) { | |
| // Submit as normal | |
| } else { | |
| $scope.signup_form.submitted = true; | |
| } | |
| } | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment