programer.tips, another cool thing from @nghuuphuoc!

grid validator

Validate a GRId (Global Release Identifier)

Validators

Improve it on Github

Options

Option HTML attribute Type Description
message data-bv-grid-message String The error message
When setting options via HTML attributes, remember to enable the validator by setting data-bv-grid="true".

Example

GRId Result
A12425GABC1234002M
A1-2425G-ABC1234002-M
A1 2425G ABC1234002 M
Grid:A1-2425G-ABC1234002-M
A1-2425G-ABC1234002-Q
<form id="gridForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-sm-3 control-label">GRId</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" name="grid" />
        </div>
    </div>
</form>
$(document).ready(function() {
    $('#gridForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            grid: {
                validators: {
                    grid: {
                        message: 'The value is not valid GRId'
                    }
                }
            }
        }
    });
});

Related validators

The following validators might be useful to you: