PDA

View Full Version : how to setup the invalidation message in the textfield



Supersuper
2 Jun 2007, 10:16 AM
Hi if I want to set some rule for this textfield such as can't more than 16chars , no space and commas. If the input string is invalid, it will show a "!" or invalidation signal at the side of text field, I wonder how can I do that.

Below I set the max length, but it only return the red line in the textfield, so I wonder how can I show the maxlengthText essage.

var sequenceNameField = new Ext.form.TextField({
fieldLabel: 'Sequence Name',
name: 'sequenceNameText',
maxLength : 16,
maxLengthText :'maximum length for this field is 16',
width:130
});


thanks

tryanDLS
2 Jun 2007, 11:14 AM
Did you include


Ext.QuickTips.init();

// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
like the examples?

Supersuper
2 Jun 2007, 4:30 PM
Did you include


Ext.QuickTips.init();

// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
like the examples?

Thank for your reply..I wonder is I have another button to do something, but the condition is the input data in the textfield must be valid. Otherwise it can't click the button. I wonder how can I check the textfield is in valid or invalid status?

Nullity
2 Jun 2007, 11:37 PM
if (myTextField.isValid()) {
// do something
}

You should browser through the docs:
http://extjs.com/deploy/ext/docs/index.html

Form.TextField:
http://extjs.com/deploy/ext/docs/output/Ext.form.TextField.html