2

我正在使用 jQuery alertify 提示http://alertifyjs.com/prompt.html

有没有办法通过直接定义属性来强制文本框?

谢谢

4

1 回答 1

1

elements您可以使用属性获取对输入框的引用:

alertify.prompt().set('onshow',function(){
   $(this.elements.content).find('.ajs-input').attr('required', true); 
});

但这不会阻止对话框在您按下 OK 时关闭,以防止您需要检查 value 参数并在其为空时取消 close 事件:

alertify.prompt('Input required')
        .set('onok', function(e, value){
            if(!value) e.cancel = true; 
         });
于 2015-09-27T08:56:32.333 回答