Hello!

I'm currently working on a login. I have two separate vendors who have given me code that does half of what I asked. haha. I'm attempting to have the user submit their information, which will carry over into the login on the following window, and have the form clear after the information is submitted.

The original code they gave me didn't work and I've now managed to get both to submit the information; unfortunately, one code simply submits the data and carries over the information but doesn't clear while the other submits the data without carrying over the information but does clear the field.... frustrating!! I'm doing what I can with my limited knowledge of javascript and have found myself at an impasse.

CODE THAT DOESN'T CLEAR BUT SUBMITS DATA
Code:
<script type="text/javascript"> 
function post_to_url( params, method) 
{
method = method || "post"; // Set method to post by default, if not specified. 
var form = document.getElementById("form1");
form.setAttribute("method", method);
form.setAttribute("target" , "_blank");
var path= "#";
form.setAttribute("action", path);
form.submit();
 }     
 function ValidateSubmit()
 {
   if(document.getElementById("txtUsername").value=="")
   {
   alert("Please enter username.")
   return false;
   }
   return true;
 }
</script>
</head>
<body>
<h3 class="login_header"> Login1</h3>
<ul style="display:block;">
  <li class="loginWidget">

<form id="form1">
User Name:
<input type ="text" name ="txtUsernameRL" id="txtUsername" value=""/>
<div class="SubmitEnrol" style="margin-top: 5px;">
        <input type="button" value="Submit" name="Submitbtn" id="Submitbtn" class="submitLogIn bigBtn" onsubmit='return doLoginRefresh()' onclick="if(!ValidateSubmit()){return;} else {post_to_url(txtUsername.value,'post')}" />
</form>
</li>
</ul>
CODE THAT CLEARS BUT DOESN'T SUBMIT DATA
Code:
<script type='text/javascript'>
	function setAction()
	{
		var x = document.forms.Remote1;
		x.action = '#';
	}
	function doLoginRefresh()
	{
		var x = document.forms.Remote1;
		
		if (x.UserIDVisible.value != "") {
			x.UserID.value = x.UserIDVisible.value;
			x.UserIDVisible.value = "";
			
			setAction();
			return true;
		} else {
			alert("Please enter username."); 
			return false;
		}	
	}
</script>  

<h3 class="login_header">Login</h3>
<ul style="display:block;">
<li class="loginWidget">
<form action='' method='post' target='_blank' onsubmit='return doLoginRefresh()' id='Remote1'>
<input type="hidden" id='UserID' name="UserID" value="" />
<label>User ID</label><br />
<div class="SecurHoder"><input class="Cid" type="text" id='UserIDVisible' name="UserIDVisible" value="" size="20" maxlength="20" /><span class="icoSecur"></span></div><br/>
<div class="SubmitEnrol"><input type="submit" value="login" class="submitLogIn bigBtn" />
</div>
</form>
</li>
</ul>
Any help is greatly appreciated. Thank you!