I am using Bootstrap to add some form of visual validation for form fields:
<div class="span1" style="min-width: 20px;">
<input type="number" min="0.1" max="40" step="0.1" value="1" data-field="numberField" class="input-mini" style="width: 40px">
</div>
Is it possible to have the text box show red highlight when its not numeric, or numeric with dots or comma (euro)?
Same as below (upvoted) since it does 90% of the job, except assuming by your comment that you want bootstraps warning class applied to the input.
All of these classes are defined on Bootstraps website (getbootstrap.com). So you want to apply the input classes which I believe are on the "components" page.
Use jQuery's addClass() given the event that @Reza layed out:
var val = $("#inputId").val();
if(Math.floor(val) == val && $.isNumeric(val))
$("#inputId").addClass('input-warning');
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments