programer.tips, another cool thing from @nghuuphuoc!

id validator

Validate identification number

Validators

Improve it on Github

Options

Option HTML attribute Type Description
country* data-bv-id-country String An ISO-3166 country code.
It's dynamic option
message data-bv-id-message String The error message
When setting options via HTML attributes, remember to enable the validator by setting data-bv-id="true".

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
39053344705
390.533.447-05
111.444.777-35
231.002.999-00
3 Bulgari EGN BG
7523169263
8032056031
803205 603 1
8001010008
7501020018
7552010005
7542011030
8019010008
4 Chile RUN/RUT CL
76086428-5
22060449-7
12531909-2
5 China CN
450202201409072332
22011219930407001X
110108601017023
999999199304070016
6 Croatia OIB HR
33392005961
33392005962
7 Czech RC CZ
7103192745
991231123
1103492745
590312123
8 Denmark CPR DK
2110625629
211062-5629
511062-5629
9 Estonia isikukood EE
37605030299
10 Finland HETU FI
311280-888Y
131052-308T
131052-308U
310252-308Y
11 Iceland Kennitala IS
120174-3399
1201743399
0902862349
12 Ireland PPS IE
6433435F
6433435FT
6433435FW
6433435OA
6433435IH
1234567TW
1234567FA
6433435E
6433435VH
13 Latvia Personas kods LV
161175-19997
16117519997
161375-19997
14 Lithuania Asmens kodas LT
38703181745
38703181746
78703181745
38703421745
15 Macedonia ЕМБГ MK
16 Montenegro JMBG ME
17 Netherlands BSN NL
111222333
941331490
9413.31.490
111252333
18 Romania CNP RO
1630615123457
1800101221144
8800101221144
1632215123457
1630615123458
19 San Marino SM
20 Serbia JMBG RS
21 Slovakia RC SK
7103192745
991231123
7103192746
1103492745
22 Slovenia EMŠO SI
0101006500006
23 South Africa South African ID ZA
8001015009087
8001015009287
8001015009086
24 Spain DNI/NIE ES
54362315K
54362315-K
X2482300W
X-2482300W
X-2482300-W
54362315Z
X-2482300A
25 Sweden personnummer SE
8112289874
811228-9874
811228+9874
811228-9873
26 Switzerland AHV-Nr/No AVS CH
756.1234.5678.95
7561234567895
27 Thailand TH
7145620509547
3688699975685
2368719339716
1100800092310

Example

<form id="idForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-sm-3 control-label">Country</label>
        <div class="col-sm-5">
            <select class="form-control" name="countrySelectBox">
            
                
                <option value="BA">Bosnia and Herzegovina</option>
            
                
                <option value="BR">Brazil</option>
            
                
                <option value="BG">Bulgari</option>
            
                
                <option value="CL">Chile</option>
            
                
                <option value="CN">China</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>
            
                
                <option value="TH">Thailand</option>
            
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label">ID</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" name="id" />
        </div>
    </div>
</form>
$(document).ready(function() {
    $('#idForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            id: {
                validators: {
                    id: {
                        country: 'countrySelectBox',
                        message: 'The value is not valid %s ID'
                    }
                }
            }
        }
    });
});

Related validators

The following validators might be useful to you: