If you right click on page and view the source of page
You are using ASP TextBox and when it renders its Id changes. So you need to use the ClientID of control to target it in the javascript.
Rendered HTML
<table cellpadding="5" cellspacing="5">
<tr>
<td>
Email:
</td>
<td>
<input name="ctl00$ContentPlaceHolder1$TextBox1" type="text" id="ContentPlaceHolder1_TextBox1" onkeyup="OnTextKeyUp(this);" />
</td>
</tr>
<tr>
<td>
Confirm Email:
</td>
<td>
<input name="ctl00$ContentPlaceHolder1$TextBox2" type="text" id="ContentPlaceHolder1_TextBox2" />
</td>
</tr>
</table>
Change your JavaScript as below
<script type="text/javascript">
function OnTextKeyUp(txt) {
document.getElementById("<%=TextBox2.ClientID %>").value = txt.value;
}
</script>