View Full Version : changing textfield colour

03-04-2005, 04:52 PM

I have a form which contains a number of textfields, these are used to hold numerical values.
After the user has entered a value into a textfield, and he exits the textfield I want the system to check the value entered against a 'master' value, if the value entered is less than the 'master' value then I want the textfield background colour to change to red (currently white), if the value is zero or greater than the 'master' value I want the textfield background colour to be white.

I am using the 'onblur' event to capture the value entered and I have the validation working but I don't know how to change the textfield background colour

Extract of code :-

<script language="javascript">
function nsf_inner_onblur()
var txtDepth = document.Edit_Record.nsf_inner;
var txtMinDepth = document.Edit_Record.min_tread_depth;
if (txtDepth.value>0 && txtDepth.value<=txtMinDepth.value) {
alert("Warning - Tread Low");
} else {
alert("Tread Depth OK");

03-04-2005, 05:54 PM
txtMinDepth.style.background = 'red';

03-07-2005, 11:55 AM
That Works Perfectly.