Oracle Apex - Highlight Numeric Field If Less Than 0 Using jQuery

Oracle Apex - Highlight Numeric Field If Less Than 0 Using jQuery

This Oracle Apex tutorial shows how to highlight the numeric field if the value is less than 0 using jQuery. The below example will change the foreground color of the numeric field to red if the value is negative (< 0).

Highlight Field (change color) If The Value is < 0 (Negative)

The following jQuery code will check if the input item's value is numeric and it is less than 0, then will change the color to red. Put the below code in the Execute when page load section of the Oracle Apex page:

$('input').each(function(){
    if ($.isNumeric($v(this))) {
        if (parseFloat($v(this),10) < 0) {
           $(this).css({'color':'red'})
        }
    }
}).on('blur', function() {
if ($.isNumeric($v(this))) {
        if (parseFloat($v(this),10) < 0) {
           $(this).css({'color':'red'})
        }
    }
});

Output: