Validate a zip code by a country code.
Option | Equivalent HTML attribute | Type | Description |
---|---|---|---|
message |
data-bv-zipcode-message |
String | The error message |
country |
data-bv-zipcode-country |
String | A ISO 3166 country code |
Currently, the validator supports the following countries:
Country | Code |
---|---|
United State | US |
Canada | CA |
Denmark | DK |
Italy | IT |
Netherlands | NL |
Sweden | SE |
United Kingdom | GB |
UK Postcode | Result |
---|---|
EC1A 1BB | |
W1A 1HQ | |
M1 1AA | |
B33 8TH | |
CR2 6XH | |
DN55 1PT | |
AI-2640 | |
ASCN 1ZZ | |
GIR 0AA |
<form id="postcodeForm" class="form-horizontal">
<div class="form-group">
<label class="col-lg-3 control-label">UK postcode</label>
<div class="col-lg-5">
<input type="text" class="form-control" name="postcode" />
</div>
</div>
</form>
<script>
$(document).ready(function() {
$('#postcodeForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
postcode: {
validators: {
zipCode: {
country: 'GB',
message: 'The value is not valid UK postcode'
}
}
}
}
});
});
</script>
Comments
If you want to report a bug, please submit the issue on Github. Do NOT post the issue here.
For a general question or feedback, use the form below.