Forum Moderators: open

Message Too Old, No Replies

Clear form after submit

         

th1chsn

7:39 pm on Jul 12, 2006 (gmt 0)

10+ Year Member



I have a form where the target=_blank. Can someone help me figure out how to clear the form after submission?

Here is what I have:

<form name="frmLogin" id="frmLogin" target="_blank" autocomplete="on" onsubmit="return ValidateLogin(this)" action="authenticate.asp" method="post">

and for the button...

<input name="btnLogin" type="submit" class="button" value="Log In" />

TIA.

penders

11:44 am on Jul 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What you could do is change the onsubmit="" attribute of your form to read:

onsubmit="if(ValidateLogin(this)) {setTimeout('document.getElementById(\'frmLogin\').reset()',5000); return true;} else {return false;}"

This will reset the form after 5 secs if the JS validation passes ok. The delay is to give enough time for the form values to be passed to your authenticate.asp script. If, however, there is an incredible delay in loading 'authenticate.asp' then your form values could be lost before they get a chance to be authenticated! In which case you'd have to increase the delay.

Personally, I would have thought it was best to try and avoid the target="_blank" if possible.