View Full Version : Ext.form.TextField does not handle maxLength/size very well.
Alan Knowles
04-26-2007, 12:42 AM
There is no way to set the size or maxLength attribute of a text input.
maxLength is also handled in code, rather than let the browser handle it.
This is a workaround to use the assigned maxLength value and adding a new config option 'size'
// Textfield ignores size attribute of text..
Ext.form.TextField.prototype.size = 20;
Ext.form.TextField.prototype.initValue = function()
{
if(this.value !== undefined){
this.setValue(this.value);
}else if(this.el.dom.value.length > 0){
this.setValue(this.el.dom.value);
}
this.el.dom.size = this.size;
if (!isNaN(this.maxLength) && (this.maxLength *1) > 0 && (this.maxLength != Number.MAX_VALUE)) {
this.el.dom.maxLength = this.maxLength *1;
}
};
Arikon
04-26-2007, 08:11 AM
1. maxLength is already handled the right way (the way it handled by browser is not very good, because you can't, for example, paste long text line to TextField and then cut out some not needed characters, browset will cut you long line for maxLength chars)
2. you can use width config attribute to set TextField size
jack.slocum
04-26-2007, 02:57 PM
I agree with Arikon. Since Ext forms provide instant feedback to the user, it improves usability to allow pasting and editing or overtyping and back tracking.
You can always use autoCreate to add any attributes you want to a field.
PS: If you don't agree with how something works, that doesn't mean it's a bug. You are welcome to post in the forums to openly discuss something you think should be different.
Alan Knowles
05-15-2007, 06:13 AM
Unfortunately, the default behavior when overtyping, is to show (after a delay), that the field is invalid, using
Ext.form.Field.prototype.msgTarget = 'side';
makes this very confusing for the end user. (as their is no error "message" visable in that case - just a red warning.)
While it is beneficial in some cases to allow overtyping, Having as a default is counter-intuitive for most users...
if would be far easier to have it as configurable at least.. - something like...
if (this.useBrowserMaxLength) && !isNaN(this.maxLength) && (this.maxLength *1) > 0 && (this.maxLength != Number.MAX_VALUE)) {
this.el.dom.maxLength = this.maxLength *1;
}
when's a bug not a bug - when it's a feature ;) - not always a clear line I guess.
leandrorc
11-19-2007, 05:34 PM
I think ExtJs should not change the usual things. The most people are accustomed to use size and maxLength. So, i think it shoud work the way we are accustomed. Shoud exists a size attribute on ExtJs textfield and the maxLength shoud lock typing. By creating a maxLengthLockTyping (true or false) attribute, people that agree with you would be satisfied.
Iveco
12-14-2007, 11:53 AM
2. you can use width config attribute to set TextField size
When I use
width: 500,
to size my input (xtype: textfield, inputType: file)
Ext will do
<input type="file" name="readfile" id="ext-comp-1022" autocomplete="off" size="20" class="x-form-file x-form-field" style="width: 500px;"/>
Set a style with width: 500,
but how do I can change the size="20"?
I tried:
autoWidth: true,
width: xxx,
autoCreate true or autoCreate: {tag: "input", type: "file", size: "MYSIZE", autocomplete: "off"} this works, but some CSS style is missing then, doesnt look like extjs textfields.
Is there any other way? Or is it meant to be that way?
Running: Ext Js 2.0 final
mystix
12-16-2007, 12:32 PM
@Iveco, please start a new thread in 2.0 bugs for this issue, with a link back to this thread if necessary
p.s. this is the 1.x bugs forum, in case you didn't notice ;)
mystix
03-13-2008, 09:52 PM
that should be
autoCreate : {tag: 'input', type: 'text', maxlength: '17', autocomplete: 'off'}
instead
Omnilord
05-08-2008, 01:20 PM
Why not add a Truncate option to TextFields and default this to false. If truncate is true, then you limit the TextField length with a hard stop at the maxlength rather than an error message.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.