"Enter Key" Form Focus ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   javoso_torso
Posted On:   Thursday, May 6, 2004 01:36 AM

Hello Following situation: a form with three buttons a submit (normal html-button) a cancel (struts html:cancel button) and a reset (struts html:reset button since I need javascript to run before submition and after the result of the javascript function deciding if submiting or not I used a submit html-button (I cannot stop the struts html:submit button from submitting even if a put a javascript onClick on it, after the javascript function comes the submition (is there a way to stop it?)). For the other two buttons the struts html tags (html:cancel + html:reset). Now if the user pr   More>>


Hello



Following situation:



a form with three buttons



a submit (normal html-button)

a cancel (struts html:cancel button)

and a reset (struts html:reset button




since I need javascript to run before submition

and after the result of the javascript function deciding if submiting or not I used a submit html-button (I cannot stop the struts html:submit button from submitting even if a put a javascript onClick on it, after the javascript function comes the submition (is there a way to stop it?)).

For the other two buttons the struts html tags (html:cancel + html:reset).



Now if the user press enter (regardless where the focus is in the form) the cancel action is being activated (the form cancelled)



if I use javascript to put the focus on submit, as soon as the user click on a text field (or any other form component) the "button group focus" moves to the cancel button!

(regardless where was the focus is in the form)



How can I get the "enter key focus" staying on submit?



I already tried the struts and it works at page-load-time BUT as soon as the user click on a text field (or any other form component) the "button group focus" moves to the cancel button ! ! !



Is there a kind of "enter key" focus?



Thanks!    <<Less

Re: "Enter Key" Form Focus ?

Posted By:   Erik_Runia  
Posted On:   Thursday, May 6, 2004 06:40 AM

make the javascript method return a boolean value of true or false, and when you call the method from your "onClick" or "onSubmit" make it the value "return methodName()". If false is returned the form will not post.



As for your second problem, look into tabOrder for your form elements, it should help you with focusing within an html form.

About | Sitemap | Contact