I'm making a registration form ATM, I have it like I want it so far except the excess JavaScript code to check the values real-time (onmouseover, onmouseout, onblur etc.).
A small sample:
<tr>
<td>
<label for="name"
onmouseover="fieldSelected('name', '', 3);"
onmouseout="checkValue('name', '', 3);">
Enter your name:
</label>
</td>
<td>
<input type="text"
id="name"
name="name"
onmouseover="fieldSelected('name', '', 3);"
onmouseout="checkValue('name', '', 3);"
onblur="checkValue('name', '', 3);">
</td>
</tr>
fieldSelected makes the field background yellow if the value of the specified element (first parameter) matches the second parameter (default value) or is shorter than third parameter.
You mouseover the label or the input field and it changes the bg first to yellow, then to red (since you didn't input anything).
checkValue changes the field background to either red or green depending on the value (same parameters).
You enter something in the input field, switch to another field and it changes the background color.
Now, as you will probably notice, there's a LOT of JavaScript function calls right there (5 per each input/select field). It would be great if someone would know a way to attach those event triggers from another place (I don't usually code this dirty), not directly in the form like this and preferably to multiple IDs at once. I have jQuery here, but I'm really no expert in JavaScript.
Or maybe there's a simpler way to do this? I want that the field background color changes on all those events for maximum interactivity. Sure, it's nothing much when all the data goes to the server side but I just want it that way.