programer.tips, another cool thing from @nghuuphuoc!

cusip validator

Validate a CUSIP number

Validators

Improve it on Github

Options

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

Example

CUSIP Result
037833100
931142103
14149YAR8
126650BG6
31430F200
022615AC2
<form id="cusipForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-sm-3 control-label">CUSIP</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" name="cusip" />
        </div>
    </div>
</form>
$(document).ready(function() {
    $('#cusipForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            cusip: {
                validators: {
                    cusip: {
                        message: 'The value is not valid CUSIP'
                    }
                }
            }
        }
    });
});
<form id="cusipForm" class="form-horizontal"
    data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
    data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
    data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">

    <div class="form-group">
        <label class="col-sm-3 control-label">CUSIP</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" name="cusip"
                data-bv-cusip="true"
                data-bv-cusip-message="The value is not valid CUSIP" />
        </div>
    </div>
</form>

<script>
$(document).ready(function() {
    $('#cusipForm').bootstrapValidator();
});
</script>

Related validators

The following validators might be useful to you: