I'm working with a form for users to submit their id to a form, which carries that information over and submits to another form. I've managed to complete the function of carrying over the data; however, the field does not clear after submission. This is a bit of a security risk for our users and I was hoping someone could assist me in finding a remedy.
If altering the .value property of the form element is causing your function to become unpredictable or broken in some way, then you're doing something wrong. I'm also confused at how your form elements are retaining data if you're submitting the form. Are you submitting via AJAX? If not, they should be automatically cleared once the page refreshes.
You could try setting the .value property to "" when you actually declare the element, like so:
Anyway, after looking at your code I can see a few things that don't seem quite right. I don't know if rewriting your code will fix the errors, but it'll be worth a shot since I can't see the rest of it. Anyway:
This is unnecessary, surely? Plus, it's atrocious to look at. People really need to get into the habit of using event handlers more appropriately. In-line coding is archaic.
You're also passing in "post" when calling the function, but then you're forcing it to "post" in the function itself. The function is passing in both the .value and "post", but that's unnecessary since you're hard-coding the value. I've taken the liberty of cleaning up some of your code and rewriting it to better suit standard practice. I still can't figure out why altering .value would stop the function working. By the way, you were also missing a closing </div> tag.
<h3 class="orange_hader toggle open">Login</h3>
<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" />
document.getElementById("Submitbtn").addEventListener("click", ValidateSubmit, false);
document.getElementById("Submitbtn").addEventListener("submit", doLoginRefresh, false);
function post_to_url(params, method)
method = "post"
var form = document.getElementById("form1");
var txtUsername = document.getElementById("txtUsername").value;
form.setAttribute("target" , "_blank");
var path= "domain.com";
alert("Please enter username.")
Also, using return true and return false in your ValidateSubmit function will have no effect on the script. It's good practice to put them in, but just thought I'd throw that out there too. There's nothing to return to.
I really can't stand working with wordpress and the base of this code was provided by one of our vendors. It wasn't functioning when they sent it over and I've managed to get this far... thus the frankenstein like code before you. It would seem that the wordpress devil strikes again. It seems to not function whatsoever. I don't receive a prompt that there is no username when the field is empty.
I've just tested the above code in all browsers. I can't for the life of me figure out why it doesn't work in MSIE. The function is simply not being called when the "click" event fires. All other browsers work as expected.
For now I'm going to have to say I'm sorry but I can't help further. Someone else might be able to, though. Also, I'm not too clued up on my CSS, but isn't it illegal to have spaces in your class names?