Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clearing web-based text fields on Unix platform??

Status
Not open for further replies.

dlingo

Programmer
Nov 19, 2001
60
US
I'm working on a web-based logon screen that needs to work on both the Unix and Windows operating systems. I want the username and password fields to be cleared each time the page is loaded for security purposes. I used the following code to accomplish this in Windows:

<body onload=&quot;document.formname.password.value=''; document.formname.username.value='';document.formname.username.focus()&quot;>

Very Simple.

In Windows this is sufficient, but in Unix the password field is not cleared. Any suggestions?

Thanks in advance.
 


dlingo,

<input type=&quot;reset&quot; name=&quot;reset&quot; value=&quot;Reset&quot;>


This button should clear all your text fields provided you have the form tags set up.


fengshui_1998
 
Yes, but doesn't that involve the user clearing the fields themselves? I want it to be automatic.
 
dlingo,

I guess I don't understand your problem. If the page loads (I'm assuming a new web page) who or what puts anything in the text fields? Is this what you might be looking for?

fengshui_1998


<body onload=&quot;runthis()&quot;>

... your code here

</body>

<script language=&quot;javascript&quot;>
<function runthis() {
document.formname.txtfield1.value == &quot;&quot;
}
</script>
 
fenshui_1998,

The code you wrote above is exactly what I am currently doing and it's the correct answer in the Windows platform. However, it doesn't work on Unix based machines and I am looking for an alternative approach that will work on both platforms.

When working with the above code in Windows, whenever the user hits &quot;BACK&quot;, or &quot;RELOAD&quot; the username and password fields are cleared as they should be.

However, in Unix the username field is cleared, but the password value remains when the user hits &quot;BACK&quot; or &quot;RELOAD&quot;.
 
dlingo,

The behaviour of your browser seem strange. When you hit the BACK or RELOAD button, it is supposed re-display the page exactly as if you hit the SUBMIT button. That means that all variables posted to the page gets reloaded unless there's a &quot;TIMEOUT&quot; on the data or the data is stale. I've seen this on bank information.

So if you want to have the information cleared, DON&quot;T USE the BACK or RELOAD button. The reset button should clear all fields although I've never tried it on a UNIX workstation. It works in IE and Netscape.


fengshui_1998
 
fengshui1998,

I appreciate you help. I did figure out an alternative approach that worked on both the Unix and Windows platforms. For some reason the Unix platform was having trouble clearing a password input value using the document.formname.password.value='' syntax. I changed it around to the following syntax
onload = &quot;document.formname.reset() and everything worked fine on both platforms. Still don't know why, but at least it works on both now. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top