<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
function duplicateField(field1, field2){
var theLength = document.getElementById(field1).value.length - 1;
var theString = document.getElementById(field1).value;
for(var i=0; i str.length-1) return str;
return str.substr(0,index) + chr + str.substr(index+1);
}
function changeColorBack(fieldName){
document.getElementById(fieldName).style.color = "#000000";
}
</head>
<body>
<p>
<input id="field1" onkeyup="duplicateField('field1', 'field2');" type="text" />
</p>
<p><br />
<input id="field2" type="text" onfocus="changeColorBack('field2');" /><br />
</p>
<p>
<span id="span1"></span>
<input id="submitButton" type="submit" value="Submit" />
</p>
</body>
</html>