Jump to content

Button foucs on forms


a1ias

Recommended Posts

Hi ppl

This is not particularly php specific I imagine but does play a major part in any php driven form script so the information will be very useful.

I basically have a form on a page - in this instance a login form that asks for username and password.

Below the forms are 2 Submit buttons, a 'Lost Password' on the left and a 'Login' on the right as follows:

<td><input type="submit" name="lostpass" value="Lost Password"></td><td><input type="submit" name="login" value="Login"></td>

By default, as soon as an entry is made in one of the fields, the focus appears on the 'Lost Password' button, no doubt as it is the first button that the code comes to. The problem being that for the lazy page users who enter their username/password then hit enter instead of actually clicking on a button, they are taken to the 'lostpass' script.

Is there a way to apply the focus to the 'Login' button by default without changing the actual orientation [i](that's my daily "Lost" reference covered")[/i] of the buttons on the page.

many thanks in advance for your assistance

a1ias
Link to comment
Share on other sites

You can float the login button to the right and place it first.
[code]
<form>
<table><tr>
<td>Username:</td><td><input type="text" /></td>
</tr><tr>
<td colspan="2">
<input type="submit" name="login" value="Login" style="float:right;">
<input type="submit" name="lostpass" value="Lost Password">
</td>
</tr>
</table>
</form>
[/code]
Make sure the table is big enough to fit both buttons.
Link to comment
Share on other sites

Thanks for the responses guys, I'll play around and let you know the result as soon as my server is back up :/

I did actually try the tabindex, but I think that it quite literally works only in conjunction with tabbing between buttons.

However, I'll see what happens later :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.