Here I have a problem which I can’t get over with. This is the code and I want the script to change the form input’s color when the entered text changes:
function checkName(name)
{
if (name.value == "value1" || name.value == "value2" || name.value == "value3" || name.value == "value4" || name.value == "value5" || name.value == "value6"){
document.forms['un'].elements['name'].style.color='#ffbb00'
}
else {
document.forms['un'].elements['name'].style.color='#000000'
}
}
As you can see when the entered text matches with one of the provided ones, it should turn orange, and when not, it shall be black. (I have an input toggling this function with an onChange thing)
I just can’t make it work so I can have multiple choices on when to change color, and also change back when the statement becomes invalid. Any help?
I have an input toggling this function with an onChange thingso your Inputand function could be
An example.
You may also try
onkeyuplike this example.