Open
Bug 339573
Opened 19 years ago
Updated 2 years ago
TAB key focuses the next field in HTML form onChange event even if return value for the event was false
Categories
(Core :: DOM: Events, defect, P5)
Core
DOM: Events
Tracking
()
UNCONFIRMED
People
(Reporter: siccospam, Unassigned)
Details
Attachments
(1 file)
396 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; nl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; nl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3
When you TAB from one textfield to the next in a HTML form and use the onChange event of the first field to check the value, the focus will go to the next field, even if the return value in the onChange event was false. If you want to check for a value, the onChange event is the right place/time to do so, but if a typed textfield value was incorrect, you don't want to loose the focus on that field.
Reproducible: Always
Steps to Reproduce:
Use the HTML and javascript below to see what happens and compare with the way Internet Explorer handles it.
<html>
<body>
<script type="text/javascript">
function fieldIsValid(field){
if (field.value != "HellO WorlD"){
alert("Value is not ok.");
field.value = "";
return false;
} else{
alert("Value is ok.");
return true;
}
}
</script>
<form>
<input type="text" onChange="return fieldIsValid(this)">
<br>
<input type="text" >
</form>
</body>
</html>
Comment 1•19 years ago
|
||
Updated•19 years ago
|
Assignee: nobody → events
Component: Form Manager → DOM: Events
OS: Windows 2000 → All
Product: Firefox → Core
QA Contact: form.manager → ian
Hardware: PC → All
Version: unspecified → Trunk
Comment 2•19 years ago
|
||
Related to or equal to Bug 267675
Comment 3•16 years ago
|
||
> Related to or equal to bug 267675
Don't think so. Ref my comment on bug 267675
This bug describes the fact that ff dos'nt respect the return
value from onchange-handler and always selects next/previous/any control
according to the action which triggered the onchange-event (tab, shift/tab,
mouse-click)
The problem may be handled by:
function myOnChange(field)
{
if (field.value!='Ok value')
{
window.selectedField = field;
if (!/^Mozilla/.test(navigator.userAgent)) { field.focus(); }
else { setTimeout('window.selectedField.focus()', 1); } // Workaround for mozilla 'bug'
return false; // Respected by IE only
}
return true;
}
.. but it would have been nice if it could be fixed to work as in IE
Updated•15 years ago
|
Assignee: events → nobody
QA Contact: ian → events
Comment 4•6 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046
Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.
If you have questions, please contact :mdaly.
Priority: -- → P5
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•