Posts: 359
Name: El Phantasmo
Location: England, north west
|
I cant think why? It works with the first text field, but not with the second! They use the same script and almost identical event handlers!
Here is my HTML
Code:
<form action="" method="post" name="form1" class="contact" id="form1">
<p class="frmIntro">Feel free to message us through our contact form and we'll get back to you as soon as possible.</p>
<p>
<label for="name">Name</label>
<input name="name" type="text" id="name" size="30" maxlength="30" onfocus="active(name)" onblur="deActive(name)" />
</p>
<p>
<label for="email">E-mail</label>
<input name="email" type="text" id="email" size="30" maxlength="100" onfocus="active(email)" onblur="deActive(email)" />
</p>
Here is my javascript
Code:
// makes a text field turn white on focus
function active(field)
{
var field = document.getElementById(field);
field.style.backgroundColor="#FFF";
}
// makes a text field turn light grey on blur
function deActive(field)
{
var field = document.getElementById(field);
field.style.backgroundColor="#F2F2F2";
}
When clicking on 'email', it doesnt change colour. 'name' works perfectly though?
Also, the error message that comes up in Firefox is 'field has no properties'
Any ideas whats wrong? Thanks
|