Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    changing textfield colour

    Hi,

    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");
    }
    }
    </script>

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Try:
    txtMinDepth.style.background = 'red';

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That Works Perfectly.

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •