Validators / id

Edit on Github

Validate identification number. Support 25 countries.

Option Equivalent HTML attribute Type Description
message data-bv-id-message String The error message
country (*) data-bv-id-country String A ISO 3166 country code

The validator supports the following countries (click the sample number to validate it):

No. Country Abbreviation ID system Country code Example
1 Bosnia and Herzegovina JMBG BA
2 Brazil CPF BR
3 Bulgari EGN BG
4 Chile RUN/RUT CL
5 Croatia OIB HR
6 Czech RC CZ
7 Denmark CPR DK
8 Estonia isikukood EE
9 Finland HETU FI
10 Iceland Kennitala IS
11 Ireland PPS IE
12 Latvia Personas kods LV
13 Lithuania Asmens kodas LT
14 Macedonia ЕМБГ MK
15 Montenegro JMBG ME
16 Netherlands BSN NL
17 Romania CNP RO
18 San Marino SM
19 Serbia JMBG RS
20 Slovakia RC SK
21 Slovenia EMŠO SI
22 South Africa South African ID ZA
23 Spain DNI/NIE ES
24 Sweden personnummer SE
25 Switzerland AHV-Nr/No AVS CH

Example

<form id="idForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-lg-3 control-label">Country</label>
        <div class="col-lg-5">
            <select class="form-control" name="country">
                <option value="BA">Bosnia and Herzegovina</option>
                <option value="BR">Brazil</option>
                <option value="BG">Bulgari</option>
                <option value="CL">Chile</option>
                <option value="HR">Croatia</option>
                <option value="CZ">Czech</option>
                <option value="DK">Denmark</option>
                <option value="EE">Estonia</option>
                <option value="FI">Finland</option>
                <option value="IS">Iceland</option>
                <option value="IE">Ireland</option>
                <option value="LV">Latvia</option>
                <option value="LT">Lithuania</option>
                <option value="MK">Macedonia</option>
                <option value="ME">Montenegro</option>
                <option value="NL">Netherlands</option>
                <option value="RO">Romania</option>
                <option value="SM">San Marino</option>
                <option value="RS">Serbia</option>
                <option value="SK">Slovakia</option>
                <option value="SI">Slovenia</option>
                <option value="ZA">South Africa</option>
                <option value="ES">Spain</option>
                <option value="SE">Sweden</option>
                <option value="CH">Switzerland</option>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="col-lg-3 control-label">ID</label>
        <div class="col-lg-5">
            <input type="text" class="form-control" name="id" />
        </div>
    </div>
</form>
<script>
$(document).ready(function() {
    $('#idForm')
        .on('change', 'select[name="country"]', function() {
            // Set the country option
            var validator = $('#idForm').data('bootstrapValidator');
            validator.options.fields['id'].validators.id.country = $(this).val();
            validator.updateStatus('id', 'NOT_VALIDATED');
        })
        .bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                id: {
                    validators: {
                        id: {
                            country: 'BA',
                            message: 'The ID is not valid'
                        }
                    }
                }
            }
        });
});
</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.