Code:
<!DOCTYPE html>
<html>
<head></head>
<body>
<table border="0" cellspacing="0" width="100%" id="table1">
<tr>
<td>FIELD1</td>
<td>FIELD2</td>
<td>FIELD3</td>
</tr>
<tr>
<td><input type="text" id="field1"/></td>
<td><input type="text" id="field2"/></td>
<td><input type="text" id="field3"/></td>
</tr>
</table>
<script type="text/javascript">
(function(){
var table = document.getElementById('table1'), inputs = table.getElementsByTagName('input'), names = table.rows[0].cells,
addEvent = (function(){return window.addEventListener? function(el, ev, f){
el.addEventListener(ev, f, false);
}:window.attachEvent? function(el, ev, f){
el.attachEvent('on' + ev, function(){f.call(el);});
}:function(){return;};
})(), i = inputs.length;
while(--i > -1){
inputs[i].setAttribute('data-index', i);
addEvent(inputs[i], 'focus', function(){
var i = names.length;
while(--i > -1){
names[i].style.color = '';
}
names[this.getAttribute('data-index')].style.color = 'red';
});
}
})();
</script>
</body>
</html>
Bookmarks