Prompt Dialog

A prompt dialog is often used if you want the user to input a value. When a prompt dialog pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.
Looking for a commercial license ? Keep your source code proprietary and Buy a Commercial License Today!

Default usage


You create a prompt dialog by invoking alertify.prompt(...)

Calling alertify.prompt() the dialog parameter-less constructor will return the prompt dialog instance. You can use this syntax to modify dialog settings before showing it. Also you can get the dialog instance (singletons only) by invoking alertify.dialog('prompt');


/*
 * @title {String or DOMElement} The dialog title.
 * @message {String or DOMElement} The dialog contents.
 * @value {String} The default input value. 
 * @onok {Function} Invoked when the user clicks OK button.
 * @oncancel {Function} Invoked when the user clicks Cancel button or closes the dialog.
 *
 * alertify.prompt(title, message, value, onok, oncancel);
 * 
 */
alertify.prompt( 'Prompt Title', 'Prompt Message', 'Prompt Value'
               , function(evt, value) { alertify.success('You entered: ' + value) }
               , function() { alertify.error('Cancel') });

Overloads

For convenience, the following overloads are also available:


/*
 * @message {String or DOMElement} The dialog contents.
 * 
 * alertify.prompt(message);
 *
 */
alertify.prompt('Prompt Message');

/*
 * @message {String or DOMElement} The dialog contents.
 * @value {String} The default input value. 
 *
 * alertify.prompt(message, value);
 *
 */  
alertify.prompt('Prompt Message', 'Prompt Value');

/*
 * @message {String or DOMElement} The dialog contents.
 * @value {String} The default input value. 
 * @onok {Function} Invoked when the user clicks OK button.
 *
 * alertify.prompt(message, value, onok);
 *
 */  
alertify.prompt('Prompt Message', 'Prompt Value'
               , function(evt, value) { alertify.success('You entered: ' + value) });

/*
 * @message {String or DOMElement} The dialog contents.
 * @value {String} The default input value. 
 * @onok {Function} Invoked when the user clicks OK button.
 * @oncancel {Function} Invoked when the user clicks Cancel button or closes the dialog.
 *
 * alertify.prompt(message, value, onok, oncancel);
 *
 */  
alertify.prompt( 'Prompt Message', 'Prompt Value'
               , function(evt, value) { alertify.success('You entered: ' + value) }
               , function() { alertify.error('Cancel') });