| View previous topic :: View next topic |
| Author |
Message |
neilr
Joined: 29 Apr 2007 Posts: 1
|
Posted: Sun Apr 29, 2007 9:06 pm Post subject: Form Validation - Object not always displayed on page |
|
|
I have an ASP web page which is used to logon to a database, when you are not logged on the web page only displays the Username and Password text boxes. Once logged on neither of these text boxes are displayed. I want the Username text box to recieve focus when the page loads which I can do but after you logon my function still tries to give the Username text box focus even though it does not exist which results in the following error -
Error: 'document.logon.username' is null or not an object
Code: 0
Any help would be greatly appreciated.
Many thanks
neilr |
|
| Back to top |
|
 |
|
|
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Mon Apr 30, 2007 8:34 pm Post subject: Re: Form Validation - Object not always displayed on page |
|
|
The sloppy way to do it, in my opinion, would be to create an input box named username and make it hidden (input type='hidden') on a successful login. Not sure if you would get an error trying to give focus to a hidden element or not though. The better way to do it would be to code the program so that the focus is skipped somehow, but I have no idea how to tell you to do that. Maybe you could check to see if the object exists before giving it focus? (something like if(document.logon.username != null)) Hope this helps.
-Mike |
|
| Back to top |
|
 |
|