v0.5.3 is released on 2014.11.05!
Options
| Option | HTML attribute | Type | Description |
|---|---|---|---|
message |
data-bv-color-message |
String | The error message |
type |
data-bv-color-type |
String|String[] |
The type of color. It can be:
|
When setting options via HTML attributes, remember to enable the validator by setting data-bv-color="true".
Supported types
Following is the list of supported types:
The keyword type accepts the following colors:
| Starting with | Colors |
|---|---|
| A | |
| B |
|
| C |
|
| D |
|
| F | |
| G | |
| H | |
| I | |
| K | |
| L |
|
| M |
|
| N | |
| O | |
| P |
|
| R | |
| S |
|
| T | |
| V | |
| W | |
| Y | |
Example
<form id="colorForm" class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label">Color</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="color" />
</div>
</div>
</form>$(document).ready(function() {
$('#colorForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
color: {
validators: {
color: {
type: ['hex', 'hsl', 'hsla', 'keyword', 'rgb', 'rgba'], // The default value for type
message: 'The value is not valid color'
}
}
}
}
});
});<form id="colorForm" 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">Color</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="color"
data-bv-color="true"
data-bv-color-type="hex,hsl,hsla,keyword,rgb,rgba"
data-bv-color-message="The value is not valid color" />
</div>
</div>
</form>
<script>
$(document).ready(function() {
$('#colorForm').bootstrapValidator();
});
</script>Related validators
The following validators might be useful to you: