How to add a MessageBox prompt in Extjs with mandatory input

152 Views Asked by At

Is there any way to add mandatory check for the input to the MessageBox prompt in Extjs like we use allowblank for textfields?

1

There are 1 best solutions below

1
mcg1103 On

New answer:

You are correct. The Ext.Msg class is a singleton so you can't really mess much with buttons or functionality, i see that now. The function that gets called on a button press is the same for all buttons... can't stop the hide with the base functionality.

So the best thing to create an instance of Ext.MessageBox and add the needed validation and button disabling and enable. Here is a quick fiddle i put together showing how I would do that.

Message Box Fiddle

Original answer:

the Ext.Msg.prompt method accepts an argument (last argument, prompt) that is the field configuration.

from the docs:

Ext.Msg.prompt(
        'Welcome!',
        'What\'s your name going to be today?',
        function (buttonId, value) {
            console.log(value);
        },
        null,
        false,
        null,
        {
            autoCapitalize: true,
            placeHolder: 'First-name please...'
        }
    );