Click to See Complete Forum and Search --> : How to use a key press to submit


frank_stain
06-17-2005, 10:39 AM
On my Logon screen if someone presses return i want that to act like the button to submit details.

i'm sure it can be done

any help very welcome

thanks

frank

silverbullet24
06-17-2005, 10:41 AM
are you trying to do this without the "submit" button showing?

frank_stain
06-20-2005, 03:07 AM
No the submit button is showing.

currently you must click it or tab through username, password, then submit and hit return.

is there any way that i can do it so it checks when return is pressed on password field.

although in the process of writing this i have had a moment of clarity on how i can do it d'oh

Cstick
06-20-2005, 07:59 PM
I use the below javascript and onkeypress event to catch the return key press on textboxes and force submitting on a particular button.


onkeypress="fnTrapKD('btnSearch',event);"



function getObject(obj){if(document.getElementById){return document.getElementById(obj);}else{if(document.all){return document.all[obj];}}}
function fnTrapKD(btn, event){
var btn = getObject(btn);
if (document.all){if (event.keyCode == 13){event.returnValue=false;event.cancel = true;btn.click();}}
else{if (event.which == 13){event.returnValue=false;event.cancelBubble = true;btn.click();}}
}