open dhtmlxmessage.js and modify modal_key function:
function modal_key(e){
if (_dhx_msg_cfg){
e = e||event;
if ((e.target||elsrcElement).className == "dhtmlx_popup_input") return true;
var code = e.which||event.keyCode;
if (dhtmlx.message.keyboard){
if (code == 13 || code == 32)
callback(_dhx_msg_cfg, true);
if (code == 27)
callback(_dhx_msg_cfg, false);
}
if (e.preventDefault)
e.preventDefault();
return !(e.cancelBubble = true);
}
}
add the following common function
function askAge(callback) {
var t = document.createElement("DIV");
t.innerHTML = "<div>What is your age?</div>"+
"<div><input type='text' value='' class='dhtmlx_popup_input'></div>";
var id = "dhxmsgId_"+new Date().getTime();
dhtmlx.confirm("<div id='"+id+"'></div>", function(r){
if (r == true) r = t.lastChild.firstChild.value;
callback(r);
t = null;
});
document.getElementById(id).appendChild(t);
}