I want to be able to change the background color of the text field within a form validate - I can't seem to get it to work
I tried a few different ways with not much sucess...
Here's the code:
function validateForm(f) {
if (f.sirname.value.length < 1) {
document.getElementById("sir_Name1").setAttribute('background', "#FFFF10");
document.getElementById("sir_Name1").value="type in first name";
}
OR
if (f.sirname.value.length < 1) {
document.forms["billShip"].elements["sir_Name1"].setAttribute="background:FFFF10";
document.forms["billShip"].elements["sir_Name1"].value="type in first name";
}
I also tried using "style" but came up with an error.
Here's the form code:
<form action="form_results.pl" name="billShip" onSubmit="return validateForm(this)" method="post">
<input class="Arial10Regular" type=text name="sirname" size=25 maxlength=50 id="sir_Name1" style="background:#FF0000;">
</form>
Please help.
Thanks,
Rich
I tried a few different ways with not much sucess...
Here's the code:
function validateForm(f) {
if (f.sirname.value.length < 1) {
document.getElementById("sir_Name1").setAttribute('background', "#FFFF10");
document.getElementById("sir_Name1").value="type in first name";
}
OR
if (f.sirname.value.length < 1) {
document.forms["billShip"].elements["sir_Name1"].setAttribute="background:FFFF10";
document.forms["billShip"].elements["sir_Name1"].value="type in first name";
}
I also tried using "style" but came up with an error.
Here's the form code:
<form action="form_results.pl" name="billShip" onSubmit="return validateForm(this)" method="post">
<input class="Arial10Regular" type=text name="sirname" size=25 maxlength=50 id="sir_Name1" style="background:#FF0000;">
</form>
Please help.
Thanks,
Rich