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
https://forums.phpfreaks.com/topic/11570-button-foucs-on-forms/
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
https://forums.phpfreaks.com/topic/11570-button-foucs-on-forms/#findComment-43733
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.