Search code examples
extjsextjs4extjs4.1extjs4.2extjs3

Regular Expression for prompt of Ext.MessageBox


i prompt the user to fill the combination of alphabets and number.

Here is the code:

 Ext.Msg.show({
    title : 'you can enter alphabets and number',
    msg : 'Your value',
    buttons: Ext.Msg.OKCANCEL,
    scope : this,
    prompt:true
});

Although it prompt to fill the value, but in that field i want to add regular expression.

i dont want to add textfield or use the window. Please help , if it is possible to add regular expression on prompt.


Solution

  • I know you said you do not want to use a window, but you could achieve this through a Window object with a form panel and a text field with a regex configured.

    Something like this:

    Ext.QuickTips.init();    
    var win = new Ext.Window({
            title: 'You can enter alphabets and number',
            modal: true,
            items : [{
                xtype:'form',
                itemId: 'myForm',
                autoheight:true,
                width:300,
                padding:5,
                border:false,
                unstyled:true,
                style: 'background-color:#CCD8E7;',
                items: [{
                    xtype: 'textfield',
                    fieldLabel: 'Your value',
                    regex: new RegExp('^[a-zA-Z0-9]+$'),
                    regexText: 'You must enter letters and numbers only',
                    emptyText: 'Use Letters and Numbers'
                }],
                bbar: [{
                    text:'Submit',
                    handler: function() {
                        //Form submit here
                    }
                }]
    
            }]
        });
    
        win.show();