Highlight Numeric Field If Less Than 0 Using jQuery in Oracle APEX

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) in Oracle APEX

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'})
        }
    }
});

 

Vinish Kapoor
Vinish Kapoor

An Oracle ACE and software veteran with 25+ years of experience, passionate about AI and IT innovation.

guest

0 Comments
Oldest
Newest Most Voted