I’m trying to create a form that allows the user to input values, for an order form. When the form is loaded, it needs to highlight all the rows that have nothing in them, or where the value is more than 100, then unhighlight them when this is corrected.
Also, there is a submit button – this needs to be disabled when any of the text boxes are highlighted
Here’s the code i have so far – does anyone have any ideas?
$(':text').focusin(function() {
var inp = $(this).val();
if (inp > 100) {
$(this).css('background-color', 'red');
}
if (inp.length < 1) {
$(this).css('background-color', 'red');
}
if (inp.length > 0 && inp <= 100) {
$(this).css('background-color', 'white');
}
});
$(':text').change(function() {
var inp = $(this).val();
if (inp > 100) {
$(this).css('background-color', 'red');
}
if (inp.length < 1) {
$(this).css('background-color', 'red');
}
if (inp.length > 0 && inp <= 100) {
$(this).css('background-color', 'white');
}
});
I think this does the trick nicely, http://jsfiddle.net/fr85u/
HTML
JS
CSS