if textbox is asp.net server control then this will not work... as after rendering textbox id will become different.
document.getElementById("txtLastOptOutDate").focus();
instead try this:
document.getElementById('<%=txtLastOptOutDate.ClientID%>').focus();