Skip to main content
July 19, 2009
Question

Set focus to a button

  • July 19, 2009
  • 2 replies
  • 1307 views

Hi everyone,

I have been searching for a while without success so would like to ask if anyone can help me here.

I have a login page with jusy username and password text fields and a login button.

I would liek users to be able to hit the enter key to activate the login process.

My code currently is

<cfformgroup type="panel" label="Development Area" height="130" style="cornerRadius: 0;">
<cfinput type="text" name="username" width="150" label="Username">
<cfinput type="password" name="password" width="150" label="Password">
<cfformgroup type="horizontal">
<cfinput type="submit" name="login_user" height="22" width="150" value="Log In" style="#buttonStyle#">
</cfformgroup>
</cfformgroup>
</cfformgroup>

This works fine but only if the user uses the mouse to click the login button.

I think it is maybe something to do with "if key is 13 then do sonmething" but I can't seem to get the code right

Anyideas please??

Thanks in advance

This topic has been closed for replies.

2 replies

July 20, 2009

Plz Try this..

<cfform

>

<cfformgroup type="panel" label="Development Area" height="130" style="cornerRadius: 0;"

>

<cfinput type="text" name="username" width="150" label="Username"

>

<cfinput type="password" name="password" width="150" label="Password"

>

<cfformgroup type="horizontal"

>

<cfinput type="submit" name="login_user" height="22" width="150" value="Log In" style="#buttonStyle#">

</cfformgroup>

</cfformgroup>

</cfform>

<cfif

Isdefined("login_user")>

<cfdump var="Do your action here">

Inspiring
July 19, 2009

make it an html form.

July 19, 2009

Don't suppose you have an example to share - sorry - am very new to all this and am really trying by myself but struggling....suppose we all start somewhere

Inspiring
July 19, 2009

<form action="somewhere" method="post">

<input type="text" name="username">

<input type="password" name="password">

<input type="submit" value="Keep it Simple">