1 //Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
2 //For full source code, 100's more DHTML scripts, and TOS,
3 //visit http://www.dynamicdrive.com
5 var highlightcolor="yellow"
7 var ns6=document.getElementById&&!document.all
11 //Regular expression to highlight only form elements
12 var intended=/INPUT|TEXTAREA|SELECT|OPTION/
14 //Function to check whether element clicked is form element
15 function checkel(which){
16 if (which.style&&intended.test(which.tagName)){
17 if (ns6&&eventobj.nodeType==3)
18 eventobj=eventobj.parentNode.parentNode
25 //Function to highlight form element
26 function highlight(e){
27 eventobj=ns6? e.target : event.srcElement
29 if (checkel(previous))
30 previous.style.backgroundColor=''
32 if (checkel(eventobj))
33 eventobj.style.backgroundColor=highlightcolor
36 if (checkel(eventobj))
37 eventobj.style.backgroundColor=highlightcolor