-
-
Save moafzalmulla/d9de73266dec0660d3f0 to your computer and use it in GitHub Desktop.
UK Postcode Validator using angular js and ng-pattern. Full Explanation at http://www.clearcoders.co.uk/
This file contains 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
<div class="form-group"> | |
<div class="col-xs-7"> | |
<label for="postcode">Postcode</label> | |
<input type="text" name="postcode" placeholder="Postcode" ng-pattern="/^[a-z]{1,2}[0-9][a-z0-9]?\s?[0-9][a-z]{2}$/i" required ng-minlength="5" ng-maxlength="8" ng-model="complaint.postcode" ng-change="formatPostcode()" class="form-control" /> | |
<div class="col-xs-12" ng-messages="reclaim.postcode.$error" ng-if="reclaim.$submitted || reclaim.postcode.$dirty"> | |
<div class="text-warning" ng-message="minlength">Postcode is too short.</div> | |
<div class="text-warning" ng-message="pattern">Postcode is not in the correct format.</div> | |
<div class="text-warning" ng-message="maxlength">Postcode is too long.</div> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment