Closed
Bug 196148
Opened 21 years ago
Closed 20 years ago
maxLength property of textbox isn't work
Categories
(Core :: XUL, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: surkov, Assigned: jst)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; ru-RU; rv:1.2.1) Gecko/20021123 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; ru-RU; rv:1.2.1) Gecko/20021123 Maxlength property doesn't affect maximum number of symbol in <input type="text"> element. It doesn't affect maximum number of symbol in textbox element too. Reproducible: Always Steps to Reproduce: create new document with the following content <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> <html:input type="text" id="txt"/> <button oncommand="var txt=document.getElementById('txt'); alert(txt.maxlength)" label="get property maxlenth"/> <button oncommand="var txt=document.getElementById('txt'); txt.maxlength=10" label="set property maxlenth"/> <button oncommand="var txt=document.getElementById('txt'); alert(txt.getAttribute('maxlength'))" label="get attr maxlenth"/> <button oncommand="var txt=document.getElementById('txt'); txt.setAttribute('maxlength', '15')" label="set attr maxlenth"/> </window> Click the button 'set property maxlength'. Maxlength property will be set to 10. Click the button 'get attr maxlength'. You'll see the empty message box, it means attribute maxlength wasn't set. Then click the button 'set attr maxlength'. Maxlength attribute will be set to 15. Click the button 'get property maxlength'. You'll see message box with 10, it means property wasn't set. Actual Results: When you change the maxlength property then maxlength attribute doesn't change. When you change the maxlength attribute then property maxlength doesn't change Expected Results: When you change the maxlength property than the maxlength attribute also must be changed to the same value and vice versa
Comment 1•21 years ago
|
||
That's because the attribute is "maxLength" not "maxlength" (note the capital L). See http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-54719353 for more details.
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Reporter | ||
Comment 2•21 years ago
|
||
The binding for textbox (chrome://global/content/bindings/textbox.xml) uses maxlength when it should use maxLength.
Status: RESOLVED → UNCONFIRMED
Component: DOM HTML → XP Toolkit/Widgets: XUL
Resolution: INVALID → ---
Reporter | ||
Comment 3•20 years ago
|
||
There is no problem for html:input element. There is problem only for xul:textbox element. It's no possibility to set max length of text by maxLength property of textbox. It's needed to modify maxLength property to fix this problem: <property name="maxLength" onset="this.inputField.maxLength = val; return val;" onget="return this.inputField.maxLength;"/> or <property name="maxLength" onset="this.inputField.setAttribute('maxlength', val); return val;" onget="return this.inputField.getAttribute('maxlength');"/>
Reporter | ||
Comment 4•20 years ago
|
||
To comment#3. Sorry. This is not the best way to fix this problem. You should change 'maxLength' property as follows: <property name="maxLength" onset="this.setAttribute('maxlength', val); return val;" onget="return this.getAttribute('maxlength');"/>
Summary: It is impossible to set up maxlength attribute by maxlength property → maxLength property of textbox isn't work
Reporter | ||
Comment 5•20 years ago
|
||
It also makes sense to change 'value', 'type', 'disabled', 'size' and 'readonly' properties since they do not modify corresponding attributes. I don't think we should create a new bug for this. Let's update this bug instead.
Reporter | ||
Comment 6•20 years ago
|
||
To comment#5. Let's not create a new bug entry for this. The current bug will go away once we fix this new problem, and I think it's sufficient to have the current bug only.
Reporter | ||
Comment 7•20 years ago
|
||
To comment#4. fix: <property name="maxLength" onset="this.setAttribute('maxlength', val); return val;" onget="return this.inputField.getAttribute('maxlength');"/>
Comment 8•20 years ago
|
||
does fix to bug 277657 fix this?
Reporter | ||
Comment 9•20 years ago
|
||
Exactly it fix. But I propose to fix something more (see comment #5). I think it would be better to fix thease bugs like I propose in comment #7. Otherwise I guess it's needed to create new bug (also see comment #5).
Comment 10•20 years ago
|
||
ok, then I think you should file a separate bug for issue in comments 5-7. It took some time for me to figure out what this bug is about. (First issue is the same as in bug 277657, second is about replacing |this.inputField.prop = value| with |this.setAttribute()| in property setters/getters of (at least) textbox - comment 5). I am not sure what are the rules on how properties' and attributes' values relate to each other. Sometimes they are in sync (property getter/setter gets/sets attribute value; e.g. textbox.disabled), sometimes not (maxlength).
Reporter | ||
Comment 11•20 years ago
|
||
Ok. I posted a bug (https://bugzilla.mozilla.org/show_bug.cgi?id=277892). I belive properties and corresponing attributes should be coordinated. Otherwise it adds redundant headache.
Comment 12•20 years ago
|
||
closing this one, as part of it is bug 277657 and the other part is bug 277892.
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago → 20 years ago
Resolution: --- → WORKSFORME
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: desale → xptoolkit.widgets
You need to log in
before you can comment on or make changes to this bug.
Description
•