-
19 Oct 2008 6:05 AM #1
Textbox maxlength attribute behavior
Textbox maxlength attribute behavior
In HTML, the maxlength attribute of a Textbox prevents user from typing texts greater than what is specified by maxlength attribute.
However, GXT's TextField.setMaxLength(...) method is used for max length validation only. It does not prevent user from typing texts greater than max length.
Is there any HTML maxlength equivalent attribute exist in GXT's TextField widget?
Thanks,
Majain
-
20 Oct 2008 5:14 PM #2
Anyone has idea on how to set the maxlength html (prevent user from typing more than the length specified) attribute on TextField widget?
-
20 Oct 2008 5:25 PM #3
There's probably some additional configuration you need to do if this is similar to ExtJS. Search ExtJS forums and you'll find something.
PHP Code:fieldLabel: 'First Name',
id: 'firstname',
name: 'FirstName',
//use autoCreate so the maxlength setting for form textfield and
//numberfield components respected on onkeyup/onkeydown, rather
//than just when the form is submitted.
autoCreate : {
tag : 'input',
type : 'text',
name : 'FirstName',
//if don't specify this in autoCreate then just specifies size="6"
maxlength : 6
},
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
13 Nov 2008 10:08 AM #4
Majain,
I have the same problem! Anyone have a suggest?
This is the basic function for a GUI framework.
Eldon
-
16 Dec 2008 6:59 AM #5
-
16 Dec 2008 7:15 AM #6
Hello,
this is really easy to implement:
SvenCode:TextField<String> text = new TextField() { @Override public void setMaxLength(int m) { super.setMaxLength(m); if (rendered) { getInputEl().setElementAttribute("maxLength", m); } } @Override protected void onRender(Element parent, int index) { super.onRender(parent, index); getInputEl().setElementAttribute("maxLength", getMaxLength()); } };
-
16 Dec 2008 7:33 AM #7
-
2 Feb 2012 9:52 AM #8
We have been using this code faithfully with our TextFields, but recently we've needed to implement this same logic with a text area and no matter what I try it doesn't work. Any quick solutions??


Reply With Quote