Created
December 4, 2013 12:55
-
-
Save inelgnu/7787023 to your computer and use it in GitHub Desktop.
Gist de la présentation de ce midi sur les forms Angularjs
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
<html> | |
<head> | |
<title>Angular App</title> | |
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"> | |
<style type="text/css"> | |
input {margin:10px ;} | |
input.ng-invalid.ng-dirty { | |
border-color: red; | |
} | |
input.ng-valid.ng-dirty { | |
border-color: green; | |
} | |
</style> | |
</head> | |
<body ng-app> | |
<form name="form" no-validate> | |
<div> | |
<input type="text" ng-model="user.username" name="username" ng-minlength="3" ng-maxlength="255" required/> | |
</div> | |
<div> | |
<input type="text" ng-model="user.email" name="email" | |
ng-pattern="/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/" required/> | |
<span ng-show="form.email.$dirty && form.email.$error.required">email is required</span> | |
<span ng-show="form.email.$dirty && form.email.$error.pattern">email is invalid</span> | |
</div> | |
<div> | |
<input type="text" ng-model="user.password" name="password" required/> | |
</div> | |
<button ng-disabled="form.$invalid" class="btn btn-success">Save</button> | |
</form> | |
<script src="lib/angular/angular.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment