Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #13380

Re: Clicking on Disabled Controls: What Happens?

From Stefan Weiss <krewecherl@gmail.com>
Newsgroups comp.lang.javascript, alt.html
Subject Re: Clicking on Disabled Controls: What Happens?
Followup-To comp.lang.javascript
Date 2012-04-15 00:33 +0200
Organization albasani.net
Message-ID <jmcu0g$2ld$1@news.albasani.net> (permalink)
References <lltgo7df68osn800egpq0ulqd0vna9srlm@4ax.com>

Cross-posted to 2 groups.

Followups directed to: comp.lang.javascript

Show all headers | View raw


[Followup-To set to comp.lang.javascript; I don't read alt.html]

On 2012-04-13 21:12, Gene Wirchenko wrote:
>      If I click on something that is not enabled, the validation for
> Workpoint executes.

Don't count on it. Clicking on a disabled text input field in Firefox 11
will not cause the current element to lose focus, nor will the change
event fire. Other browsers handle this situation differently.

>      If there is a validation error, an alert is issued, and the focus
> gets put back to Workpoint.  (Spare me that this not how Web pages
> should work.  "Sticky" focus on errors is what is needed and wanted.)

Okay, so you're dead set on something you know will cause some criticism
(at least in this group). Do as thou wilt, and all that, but there are
other people reading our posts, and they should know why alert()+focus()
is not a good way to do client side form validation.

I'll spare you the details if you're not listening anyway, but I will
say that I'm pretty sure you will give up your insistence on this
"feature" at some point. I've been down that road in the past (years
ago). The customer wanted it, I didn't see anything terribly wrong with
it, it got developed and deployed. Three months later, we were all sick
of the constant alerts, and I changed the form validation code to be
less patronizing and more flexible. User makes an error -> field is
marked as invalid, and a way to see the error message is provided for
each field (for example, an icon which will show the error message on
hover). The user can continue to fill out the form, but will be
prevented from submitting it (you can show an alert then, if you must).
In addition to avoiding the technical issues you mentioned, this will
allow the user to fill out the form in whatever order they want.

Consider this example: user is on the phone with an angry customer, and
begins filling out a trouble ticket form. The first field is the
customer name, and it's a required field. The customer doesn't know that
and gives the error description first. User wants to tab to the text
area to write down the details, but can't, because the focus is
constantly reset to the first field. Maybe that's a contrived example;
my point is that filling out forms in a random order, with temporarily
missing/incomplete/erroneous data, should be possible with a decent web
application (within limits). Submitting the form should not.

>      However, if there is not a validation error, the focus goes off
> somewhere I know not where, AND I CAN NOT TELL WHERE.  I want the
> focus back on Workpoint.
> 
>      The focus, despite not showing on the form, can be moved.  If I
> press [Tab] immediately after this, the focus moves to the first
> enabled control on the form.  This is weird.

Is it? When the body has focus (which it will in Chrome, for example), a
tab will set the focus to the first available input (observing tabindex,
if set).

>      Ideally, I would like that when a non-enabled item is clicked on,
> that the click is ignored, that is, it is as if nothing had happened.
> 
>      If I can not have that, I would, at least, like to have the focus
> returned to Workpoint whether the validation succeeds or not.
> 
>      Unfortunately, document.currentElement does not give me a value
> that I can work with so that I can detect the weirdness. 

Did you try document.activeElement?

Be sure to check for browser support with that. AFAIK, it's supported in
the current releases of all major browsers. If you're in an intranet
with a browser monoculture, it might do what you think you need.


- stefan

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Clicking on Disabled Controls: What Happens? Gene Wirchenko <genew@ocis.net> - 2012-04-13 12:12 -0700
  Re: Clicking on Disabled Controls: What Happens? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-14 10:35 +0000
    Re: Clicking on Disabled Controls: What Happens? Denis McMahon <denismfmcmahon@gmail.com> - 2012-04-14 15:45 +0000
      Re: Clicking on Disabled Controls: What Happens? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-14 17:39 +0000
        Re: Clicking on Disabled Controls: What Happens? Denis McMahon <denismfmcmahon@gmail.com> - 2012-04-14 20:59 +0000
    Re: Clicking on Disabled Controls: What Happens? Gene Wirchenko <genew@ocis.net> - 2012-04-15 20:26 -0700
      Re: Clicking on Disabled Controls: What Happens? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-16 09:37 +0000
  Re: Clicking on Disabled Controls: What Happens? Jeff North <jnorthau@yahoo.com.au> - 2012-04-14 23:58 +1000
    Re: Clicking on Disabled Controls: What Happens? Gene Wirchenko <genew@ocis.net> - 2012-04-15 20:51 -0700
      Re: Clicking on Disabled Controls: What Happens? Jeff North <jnorthau@yahoo.com.au> - 2012-04-16 18:52 +1000
        Re: Clicking on Disabled Controls: What Happens? Gene Wirchenko <genew@ocis.net> - 2012-04-16 09:25 -0700
          Re: Clicking on Disabled Controls: What Happens? "Neil Gould" <neil@myplaceofwork.com> - 2012-04-16 13:13 -0400
            Re: Clicking on Disabled Controls: What Happens? Tim Streater <timstreater@greenbee.net> - 2012-04-16 18:32 +0100
              Re: Clicking on Disabled Controls: What Happens? Gene Wirchenko <genew@ocis.net> - 2012-04-16 10:53 -0700
          Re: Clicking on Disabled Controls: What Happens? "Jonathan N. Little" <lws4art@gmail.com> - 2012-04-16 13:44 -0400
  Re: Clicking on Disabled Controls: What Happens? Stefan Weiss <krewecherl@gmail.com> - 2012-04-15 00:33 +0200
    Re: Clicking on Disabled Controls: What Happens? Denis McMahon <denismfmcmahon@gmail.com> - 2012-04-15 00:00 +0000
      Re: Clicking on Disabled Controls: What Happens? Gene Wirchenko <genew@ocis.net> - 2012-04-15 20:27 -0700
    Re: Clicking on Disabled Controls: What Happens? Gene Wirchenko <genew@ocis.net> - 2012-04-15 20:24 -0700

csiph-web