bootstrap-slider
bootstrap-slider copied to clipboard
What about validation?
Currently, we're including your slider as a BootsFaces widget (see http://www3.bootsfaces.net/Showcase/bootstrap/Slider2.jsf). Among other things, this means we need to be able to report error messages. I agree this makes hardly ever sense, but if someone defines a validation constraint we'd like to indicate that the slider has an illegal value. Standard Bootstrap input widgets use this approach: http://getbootstrap.com/css/#forms-control-validation.
Is there anything similar for the bootstrap-slider?
This is not a thing we support. Your best bet at this time would be to either:
- use CSS to custom-color the track or the border of it
- use an error message nearby to say that the slider value is invalid
That said, I think this is a feature worth accepting a PR for, so if we were to accept one, I would like it to color the border of the slider in the same style as bootstrap inputs.
Sure, we can talk about submitting a PR. But before that, I'd like to get an idea what's a clever approach. I guess coloring the border according to the Bootstrap styles works well enough in most cases.
Following the recommended HTML code for regular input fields, we would mark the "offending" (for want of a better word) slider like so:
<div class="form-group has-error">
<label class="control-label" for="age">Please enter your age (18-65)</label>
<input id="age" data-slider-id='ex1Slider' type="text" data-slider-min="0"
data-slider-max="99" data-slider-step="1" data-slider-value="14"/>
</div>l
Does this match your ideas?
I think that would be fine, so long as the generated HTML still includes the slider class (so you're targetting .has-error .slider in your CSS). Makes sense to me.
OK! I think we'll test the idea first in BootsFaces. If the idea works out, I'll prepare a pull request for you.
(Isn't open source great? Being able to improve things actively? That's something that's much more difficult with commercial software!)
Sounds good, feel free to pass it along when you've got a working idea (just remember to follow all the PR guidelines!).
Open source is pretty nice for that, yeah. It's why we do what we do :D