|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Clear password textbox on Submit
I have an intranet page with a link to a coldfusion project log. When one clicks on the link the first cfm page is a login page. When the user hits the submit button the first page of the project log opens in a new window (and hence, subsequent pages of the project log).
The problem is that the password remains behind in the parent window. Is there any code I can include that says clear the text field when the user hits the submit button? Thanks from a newb, melissa ![]() |
|
#2
|
||||
|
||||
|
All hail JavaScript!
Code:
<script language="JavaScript" type="text/javascript">
function iLikePudding() {
document.yourForm.submit();
document.yourForm.password.value = '';
}
</script>
</head>
<body>
<form name="yourForm" method="post" action="" target="_blank">
<input type="password" name="password">
<input type="button" value="Fake Submit" onclick="iLikePudding();">
</form>
That should work, since it submits the form before resetting the field. Try it out. |
|
#3
|
|||
|
|||
|
Oh how I wish I knew JavaScript!
Unfortunately it didn't work . . . Here is what I have: Code:
<script language="JavaScript" type="text/javascript">
function AutoClearLogin() {
document.loginform.submit();
document.loginform.password.value = '';
}
</script>
<cfif #session.login# is "WrongPassword">
Password entered incorrectly. Please try again.
</cfif>
<form name="loginform" action="validatepassword.cfm" method="post" target="_blank">
<p><font size="+1">To query and view projects simply click on the Submit button (no password required).<br>
<font color="#FF0000">To modify or add a project, please enter a password and click on the Submit button.</font></p>
<p>Click the submit button to continue.</p>
<input type="password" name="pwd" size=25 maxlength=25>
<input type="button" value="Submit" onClick="AutoClearLogin();">
</form>
I'm hoping its my lack of knowledge of JavaScript that keeps me from seeing the stupid error I have undoubtedly made? Thanks for helping me out - melissa ![]() |
|
#4
|
||||
|
||||
|
You're calling your password field 'pwd' and not 'password'.
So you need to change this: document.loginform.password.value = ''; to this: document.loginform.pwd.value = ''; Hope that helps. |
|
#5
|
|||
|
|||
|
Actually I had tried that too before but forgot to change it back when I pasted the code in that last post. Still doesn't work.
I'm wondering if it has anything to do with the fact that I have the action set to go to a validatelogin.cfm page?Thanks again for your help, melissa ![]() |
|
#6
|
|||
|
|||
|
Also keep in mind that if anyone has Javascript turned off this won't work. Is there any reason why you are opening a new window and not just loading the next page into the same window?
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#7
|
|||
|
|||
|
Yes. The intranet pages are all developed from a template built in Dreamweaver. On the intranet pages are logos, big titles and huge buttons that take up a lot of real estate. These are all necessary to our organization apparently.
The project log is designed only for a smal group of people so they don't really need access to all that stuff once inside the project log. The project log itself contains a few very large table that need all the real estate they can get, hence opening a seperate page. Is there another way to clear the textbox without using JS? thanks, melissa ![]() |
|
#8
|
||||
|
||||
|
Quote:
Yes, but what's the syntax in the JavaScript errors you're getting? Also, try changing your script to this: Code:
function validateForm() {
document.formName.pwd.value = '';
}
And changing your form to this: <form onsubmit="validateForm();"> And putting your submit button back on: <input type="submit" value="Submit"> If you still get errors or the password doesn't get sent, you can have a hidden field populated with the password when the form submits and the visible one go blank. Hope that helps. |
|
#9
|
|||
|
|||
|
Okay I'm really dumb. Chalk it up to bad habits.
First off, I needed to set a value field to "" in the password paramater so that it looked like this: Code:
<input type="password" value="" name="pwd"> Second, the reason it wasn't working was because of the onClick. See, I'm a lazy computer user - I almost never use the mouse if I don't have to. I almost always use the Tab key to get around, alt key for menus, ctrl key for known and common functions, and the Enter key for buttons. So the onClick function never fired because I was never using the mouse to click on the submit button. Pretty silly huh? Where is the smiley smacking itself in the forehead? That is one I would use a lot. So I have a friend helping me to write some code to capture hitting the Enter key to submit the form as well as using the mouse to click on the submit button. Thanks all for your help - sorry to be such a noob! cheers, melissa |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Clear password textbox on Submit |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|