Highlight "red" the text box when value is not numeric, numeric with dot or comma

quarks

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)?

Don P

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.

edited at
0

Comments

0 comments
Login to comment

Related

Converting dot to comma in numeric

Numeric Validation when using a HTML Text Box

Conditional replacement of a comma with a dot in a numeric column

Kendo UI numeric text box value based on Grid row selection

VBA Highlight row if cell value is numeric

Pivoting the table not working when the column is intend to have a text & numeric value

Create a numeric value from text

2 states roundable numeric text box with knockoutjs

Numeric Text box accepts "E" character

Validate text box to limited numeric input

How to delete characters from a text box based on numeric up down value in C#?

Enum showing numeric value instead of text value

How do I split a string based on a numeric value follow by a dot '.'?

How to create comma separated list of numbers based on numeric value in column

Convert text data to a numeric value to use in a multiplication

PHP loop with increased numeric value added to text

How to get numeric value from text field?

Depending on numeric value and text, coloring table background

pandas convert text feature to numeric value

find an undetermined numeric value in a text file

Sort Dictionary (Text keys) by Numeric Value

How to remove all non numeric characters (excluding minus, dot and comma) in a string in Javascript?

Highlight entry if not 17 numeric digits

Create a numeric text box in java Swing with increment and decrement buttons

set the width of a kendo numeric text box with tag helpers

Using selenium to automate kendoUI numeric text box, without javascript

kendo numeric text box removes trailing zeros on focus

Covert a text box value to comma seperated

Replace comma and convert to numeric in r