Skip to content

Instantly share code, notes, and snippets.

@codepreneur
Last active August 29, 2015 14:03
Show Gist options
  • Save codepreneur/bc10cfd01ff91dd5b7fb to your computer and use it in GitHub Desktop.
Save codepreneur/bc10cfd01ff91dd5b7fb to your computer and use it in GitHub Desktop.
<form name="form" ng-submit="submit()" novalidate>
<fieldset style="width: 30%">
<p>Name: <input type="text" ng-model="name" name="name" ng-minlength=3 ng-maxlength=20 ng-pattern="/^[a-zA-Z]+$/" required></p>
<section ng-show="form.name.$dirty && form.name.$invalid" style="color: red;">
<p ng-show="form.name.$error.required">Your name is required</p>
<p ng-show="form.name.$error.minlength">Your name must be greater than 3 characters</p>
<p ng-show="form.name.$error.maxlength">Your name cannot be longer than 20 characters</p>
<p ng-show="form.name.$error.pattern">Only letters please!</p>
</section>
<p>Email: <input type="email" name="email" ng-model="email" required></p>
<section ng-show="form.name.$dirty && form.name.$invalid" style="color: red;">
<p ng-show="form.email.$error.email">That is not a valid email</p>
</section>
<p>Website: <input type="url" name="site" ng-model="site" required></p>
<section ng-show="form.site.$dirty && form.site.$invalid" style="color: red;">
<p ng-show="form.site.$error.url">That is not a valid website</p>
</section>
<p>Age: <input type="number" name="age" ng-model="age" min=3 max=200 required></p>
<section ng-show="form.age.$dirty && form.age.$invalid" style="color: red;">
<p ng-show="form.age.$error.min">You need to be at least 3 to use this site</p>
<p ng-show="form.age.$error.max">You are 200 or older? Really?</p>
</section>
<p><button type="submit" ng-disabled="form.$dirty && form.$invalid">Submit</button></p>
</fieldset>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment