jquery - 如何使用 HTML 5 强制提醒提示文本框?

标签 jquery alertify alertifyjs

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

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

谢谢

最佳答案

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

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

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

alertify.prompt('Input required')
        .set('onok', function(e, value){
            if(!value) e.cancel = true; 
         });

关于jquery - 如何使用 HTML 5 强制提醒提示文本框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32794648/

相关文章:

javascript - 从主窗口访问 iframe 内部属性

javascript - 如何添加关闭按钮以使用 CSS 提醒日志?

codeigniter-3 - 无法修复无法读取未定义的属性(读取 'length' )

javascript - 当一个文件已缓存时,Yepnope 不会触发完成或回调

javascript - 为什么页面重新加载时 jQuery beforeunload 不会触发?

javascript - 二维拖放 (DHMLGoodies)

javascript Aertify 无法与确认框一起正常工作

javascript - AlertifyJS 提示对话框中的多个输入框

javascript - 是否可以将 Alertify.js 的取消按钮调用的操作与 onclose 分开