Skip to content

Instantly share code, notes, and snippets.

@maltzsama
Created March 26, 2014 18:24
Show Gist options
  • Select an option

  • Save maltzsama/9789915 to your computer and use it in GitHub Desktop.

Select an option

Save maltzsama/9789915 to your computer and use it in GitHub Desktop.
Validação para coisas.
<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>
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