Velocity Reviews

Velocity Reviews (
-   HTML (
-   -   Re: How to update code so ENTER key selects OK button (

Adrienne Boswell 06-07-2010 11:38 PM

Re: How to update code so ENTER key selects OK button
Gazing into my crystal ball I observed "ScaryFruit" <no@spam.please>
writing in news:bJ6dnTTIjqCr65DRnZ2dnUVZ7oidnZ2d@brightview.c

> Hi,
> I found the below code on the web which I've adapted slightly to
> prompt for a username and password, and also so the cursor
> automatically starts in the "Username" box.

Let the user position the cursor. If the user has already started
typing in the field, and the script puts the user back at the beginning
of the field, the user may mistype the information. If the fields are
in an obvious place, the user will have no problem finding it.

> I'd also like to
> configure this so when the user pushes ENTER on the keyboard, it
> selects the OK button. Could someone show me how to do this?

What happens if I have started typing, and accidentally hit the enter
key? The wrong information will be submitted, and I will be frustrated.
Let the user use the submit button.

> (And, as an aside, if anyone can tell me the IE security settings to
> change so, when running the script from the local machine, I don't
> keep getting a warning saying IE has restricted the webpage from
> running scripts of ActiveX controls, that would also be helpful!)
> Thanks in advance.
> Sub RunScript
> OKClicked.Value = "OK"
> End Sub
> Sub CancelScript
> OKClicked.Value = "Cancelled"
> End Sub

If you hold a gun to the user's head, you may be able to get him or her
to change their security settings. VB script is always ActiveX, so will
always give that warning.

><font size="2" face="Arial">
> Username:&nbsp;&nbsp;&nbsp; </font><font face="Arial">
><input type="username" id="UserName" size="40"></font></p>
><script>document.getElementById('UserName').focus ()</script>
><font size="2" face="Arial">
> Password:&nbsp;&nbsp;&nbsp; </font><font face="Arial">
><input type="password" name="UserPassword" size="40"></font></p>
><input type="hidden" name="OKClicked" size = "20">
><input id=runbutton class="button" type="button" value=" OK "
> name="ok_button" onClick="RunScript">
> &nbsp;&nbsp;&nbsp;
><input id=runbutton class="button" type="button" value="Cancel"
> name="cancel_button" onClick="CancelScript">

Oh, the horror! The font element is deprecated in favor of CSS.
Character values must be quoted in element attributes.

Just use a regular submit button, and take out the unnecessary
scripting. Make sure that you check server side for the values you are
expecting from the client.

Adrienne Boswell at Home
Arbpen Web Site Design Services
Please respond to the group so others can share

All times are GMT. The time now is 10:36 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.