Following problem: I have some input fields of type range. jQuery mobile automatically transforms them into an input field with a slider aside. What I want to do is instant validation while typing. The validation script shall remove all non-digits. The function I use works on input field text but not for input type range.
This is my html:
<label for="my_range_input_field">label_text:</label>
<input data-type="range" type="range" name="my_range_input_field" id="my_range_input_field" value="10000" min="0" max="85000" />
This is my jQuery validation function:
$(document).delegate('#my_range_input_field', 'input', function(e) {
$(this).val($(this).val().replace(/[^\d]/g, ""));
});
The problem is, that this function deletes the whole input value and not just the non digits. I tried to debug and when using console.log to display the val I saw that it was always an empty string when not only digits were typed in the input field. I did some research and found the following: How to get the raw value an <input type="number"> field?
So there is something like a pre-validation and it seems that I can't retrieve the value I want because it's invalid and displays as empty string. Is there still a way to get that value?
Or is there at least something like a :invalid
selector for input fields of type range to show the user a red background or something?