470,821 Members | 2,104 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,821 developers. It's quick & easy.

focus/select methods (form larger than screen)

Howdy:

I'm just learning how to use focus() and select().
I have a very large form (360+ elements).
Javascript validation is launched by the 'onclick' event handler in
the "submit" button tag.

Problem:
When the element to be validated is not on the screen - since the
form is larger than the screen, then there are no visual cues to help
the user find the element that needs to be change/edited. Although a
message is provided to the user giving the text next to the element.

I would welcome advice on how to help the user find the element.

After my signature is a code sample of what I am using.
TIA
Tim
// function 'TryAgain
function TryAgain(widget,message){
alert(message);
widget.focus();
widget.select();
return false;
}
Oct 28 '05 #1
5 1305
Tim Johnson said the following on 10/27/2005 10:51 PM:
Howdy:

I'm just learning how to use focus() and select().
I have a very large form (360+ elements).
Thats not large, it is gargantuan.
Javascript validation is launched by the 'onclick' event handler in
the "submit" button tag.
Don't use the onclick of the submit button, use the onsubmit handler of
the form. There are more ways to submit a form than clicking the submit
button.
Problem:
When the element to be validated is not on the screen - since the
form is larger than the screen, then there are no visual cues to help
the user find the element that needs to be change/edited. Although a
message is provided to the user giving the text next to the element.

I would welcome advice on how to help the user find the element.


Make your pages smaller. Or, look into scrollIntoView and it's alternatives.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 28 '05 #2
Lee
Tim Johnson said:

Howdy:

I'm just learning how to use focus() and select().
I have a very large form (360+ elements).
Javascript validation is launched by the 'onclick' event handler in
the "submit" button tag.


What Randy said.
Just so you don't think it's just one person's opinion:
Never validate in the onclick handler of the submit button.
Don't make a form that big. Split it into several pages.

Oct 28 '05 #3
Lee wrote:
Tim Johnson said:
Howdy:

I'm just learning how to use focus() and select().
I have a very large form (360+ elements).
Javascript validation is launched by the 'onclick' event handler in
the "submit" button tag.

What Randy said.


Thanks Lee and Randy:
Just so you don't think it's just one person's opinion:
Never validate in the onclick handler of the submit button.
Can you elaborate on your reason? See further comments below...
Don't make a form that big. Split it into several pages.


FYI: I'd forward this opinion to the client, but he has heard
it already (from me). So, the size of the form will remain as
is for now.

FYI2: This is a form which will be
not only auto-generated, but partially auto-filled and is meant to
be printable. There is an alternative form that will be generated at
the users choice that will replace single-name checkbox groups with
multiple select lists and radio buttons with single select lists and
will be a fraction of the size.

I have moved the validation event handler to the 'form' tag and the

behavior (or lack thereof) persists. I find that if I press the "right
arrow" key the field is now visible with the cursor at the beginning
of the text and if I press the "left arrow" key the text field is now
visible with the cursor at the end of the text.

Further comments are welcome.
Thanks again.

Tim Johnson
===========
Alaska Internet Solutions
Oct 28 '05 #4
Tim Johnson said the following on 10/28/2005 12:52 PM:
Lee wrote:
Tim Johnson said:
Howdy:

I'm just learning how to use focus() and select().
I have a very large form (360+ elements).
Javascript validation is launched by the 'onclick' event handler in
the "submit" button tag.


What Randy said.

Thanks Lee and Randy:
Just so you don't think it's just one person's opinion:
Never validate in the onclick handler of the submit button.

Can you elaborate on your reason? See further comments below...


As I said, the submit button is not the only way to submit a form.
Pressing the <enter> key will submit the form and your onclick of the
submit button won't get fired. But if you use the onsubmit of the form,
it will get triggered unless the form is submitted via JS.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 28 '05 #5
Randy Webb wrote:
Tim Johnson said the following on 10/28/2005 12:52 PM:

<..sn..>
Just so you don't think it's just one person's opinion:
Never validate in the onclick handler of the submit button.


Can you elaborate on your reason? See further comments below...

As I said, the submit button is not the only way to submit a form.
Pressing the <enter> key will submit the form and your onclick of the
submit button won't get fired. But if you use the onsubmit of the form,
it will get triggered unless the form is submitted via JS.


Understood. Thanks Randy.
Oct 28 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Paul Thompson | last post: by
9 posts views Thread by Roger Withnell | last post: by
2 posts views Thread by Jesper | last post: by
8 posts views Thread by copyco | last post: by
9 posts views Thread by fidodido | last post: by
6 posts views Thread by John | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.