Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13375
| Newsgroups | comp.lang.javascript, alt.html |
|---|---|
| Subject | Re: Clicking on Disabled Controls: What Happens? |
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
| References | <lltgo7df68osn800egpq0ulqd0vna9srlm@4ax.com> |
| Message-ID | <XnsA0358025EDCC9eejj99@194.109.133.133> (permalink) |
| Date | 2012-04-14 10:35 +0000 |
Cross-posted to 2 groups.
Gene Wirchenko wrote on 13 apr 2012 in comp.lang.javascript:
> This is posted to both comp.lang.javascript and alt.html, because
> it might have to do with either JavaScript or HTML. I expect that it
> is the former, but.
> My form handler is coming along slowly, but the results are nice.
> I am now adding buttons for handling modes (adding, updating,
> deleting). When data entry is being done, only some of the controls
> are enabled. If a button or input control is disabled, it can get
> weird.
Only if your code does not account for those states.
I suggest you write code that incorporates all possible states.
> Suppose that DE is being done. Call the current input control
> Workpoint.
What is DE?
What is Workpoint?
>
> If I click on something that is not enabled, the validation for
> Workpoint executes.
Impossible, unless a higher onclick is being invoked,
and then only in IE, not in Chrome. Try:
<body onclick='alert("body")'>
<input type='submit' disabled>
</body>
> If there is a validation error, an alert is issued,
What validation error?
Of javascript or html?
Or of a function called myValidation() ?
> and the focus gets put back to Workpoint.
What is Workpoint?
> (Spare me that this not how Web pages
> should work. "Sticky" focus on errors is what is needed and wanted.)
But if the execution differs between IE and Chrome [and the other major
browsers], that is not how web pages are supposed to work, and your code
is incomplete or faulty in that sense.
> 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.
Only if your code does not specify where the focus should go.
change your code to be ready for all states.
If a text input does not have a value that is acceptable
[is that what you mean by validation?]
then the user should get a warning and should be returned to the state
where he [she?] can correct that input or by his choice cancel the
process.
What is Workpoint?
> The focus, despite not showing on the form, can be moved.
That depends on the browser, focus should be visible it is on a form
element that can be used for input under html.
You should set the focus on such element if the default is not doing that
crossbrowserwize.
> If I
> press [Tab] immediately after this, the focus moves to the first
> enabled control on the form. This is weird.
No, that is standard, if the focus is not on an inputtable input element.
However if it is, it works as expected.
Try tabbing and shift-tabbing here:
<body onload='document.getElementById("q").focus()'>
<form>
<input>
<input id=q>
<input>
<input>
</form>
</body>
> 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.
That is blissfully ignored in Chrome,
and outwardly doing the same in IE if you programme accordingly.
It would be nice if we could ignore IE altogether.
> If I can not have that, I would, at least, like to have the focus
> returned to Workpoint whether the validation succeeds or not.
What is Workpoint, the ID of an input element??
You can do that:
<form onclick='document.getElementById("Workpoint").focus()'>
or perhaps 'better':
function myValidation(inp) {
if (validateMe(inp))
document.getElementById("Workpoint").focus()
else
document.getElementById("Workpoint").focus();
}; // ;-)
> Unfortunately, document.currentElement does not give me a value
> that I can work with so that I can detect the weirdness.
There is on weirdness if your programme code is prepared for all states.
> How can I
> tell where the focus is going? (I think I would then check if the
> control is disabled, and if so, set focus back to Workpoint.)
You can tell if your code is the master, as the focus then goes wher you
want it to go [not counting that the user sets the focus somewhere else
by mouse pointing cum clicking or by tabbing or shift-tabbing.
If document.currentElement cannot reliably help you here, there is no
other javascript reachable system variable that shows the focus,
methinks. That only zero one element can have focus is an incidental fact
of life, as seen from the perspective of a single element.
Programmatically then you only know the focus state of elements where an
eventlistener signals it, I think:
<element id='el17'
onfocus = 'storeFocusPosition(this)'
onblurr = 'clearFocusPosition()'
>
[The onblurr being necessary, when you have not set the onfocus for all
possible elements on the page, which seems impossible on a scale larger
than a minimal example.]
>
> Sincerely,
>
> Gene Wirchenko
>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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