Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extjs 4 - How change default message error in field

I have a form panel in http://jsfiddle.net/7CLWy/ here is my important code

items: [{
    xtype: 'textfield',
    fieldLabel: 'First Name',
    allowBlank: false,
    msgTarget: 'under',
    name: 'firstName'
}, {
    xtype: 'datefield',
    allowBlank: false,
    fieldLabel: 'Start date',
    msgTarget: 'under'
}],

I want change default message error in field

enter image description here

How to change that. Thanks

like image 540
LookAtMeNow Avatar asked Jul 27 '13 08:07

LookAtMeNow


1 Answers

The blankText property is the validation message when a field is required, and invalidText is the text when the field generically fails validation. You can add your own custom messages in these properties. Similarly, if you happened to be doing regex-based validation with the regex property, you could use the regexText field to provide a custom validation message.

    items: [{
        xtype: 'textfield',
        fieldLabel: 'First Name',
        allowBlank: false,
        msgTarget: 'under',
        name: 'firstName',
        blankText: 'This should not be blank!'
    }, {
        xtype: 'datefield',
        allowBlank: false,
        fieldLabel: 'Start date',
        msgTarget: 'under',
        invalidText: 'This value is not a valid date!'
    }, {
        xtype: 'textfield',
        fieldLabel: 'Digits followed by A,B,or C',
        msgTarget: 'under',
        name: 'someText',
        regex: /^\d+[ABC]$/,
        regexText: 'This must be a string of digits followed by A, B, or C!'
    }]
like image 129
Chris Farmer Avatar answered Oct 01 '22 11:10

Chris Farmer