Here I have a problem that I cannot handle. This is the code, and I want the script to change the input color of the form when the input 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 one of the provided ones, it should be orange, and when not, it should be black. (I have an input that toggles this function using the onChange function) I just can't get it to work, so I may have several options when I need to change color, and also change back when the statement becomes invalid. Any help?
source
share