views:

704

answers:

3

I'm pretty new to Javascript and I'm sure this is an easy fix, but I can't figure it out.

I'm using a slightly modified version of the code from this page and I want to make the form work by entering the information and pressing enter rather than having to click the button.

FYI I've read this thread and can't work out my own answer from there. I tried changing the type to "submit" from "button" but then the login didn't work. I've also tried changing "onlick" to "onsubmit" and had the same problem.

A: 

Set the "tab index" property of your html elements with your button having the highest index (or one up after the last html element)

Jobo
+3  A: 

Use a type of "submit" but change the onclick to onclick="loginFunction(); return false;"

The return false stops the submit button from actually doing the submit.

too much php
Thanks, you guys are the best.
Evan
Hrm, now that I think of it I have my own form I need to do this to ...
too much php
A: 

Hi, If you want to submit a form on click of button instead of enter then no need to use input type="submit" instead of this you can use input type='button' and set a onclick function in this like input type="button" onclick="my_func()" and in the definiton of this function my_func you can use document.formname.submit() for submitting the form. hope it will work for you.