javascript - 提示时的 Alertifyjs 验证

标签 javascript alertifyjs

我正在使用 alertifyjs太好了,但我有一个小问题想解决,也许需要您的帮助。

使用 Prompt Component我想强制用户在输入字段中写一个“原因”,老实说我不知道​​该怎么做......

其实我的代码是这样的:

  alertify.prompt(
        'Warning!',
    'Are you sure you wish to CANCEL the order?',
    'Enter reason please...',
    function (e, reason) {
      // my code on confirm...
    },
    function () {
        return;
    }
  );

我希望你能帮忙。

最佳答案

文档显示以下内容:

alertify.prompt(
    'Warning!',
    'Are you sure you wish to CANCEL the order?',
    'Enter reason please...',
    function (e, reason) {
       if( reason == '' ) { 
           e.cancel = true;
       }
      // my code on confirm...
    },
    function () {
        return;
    }
  );

http://alertifyjs.com/prompt/onok.html
要防止对话框关闭,请设置 closeEvent.cancel = true 或使您的回调返回 false 。

关于javascript - 提示时的 Alertifyjs 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34950801/

相关文章:

jquery - 显示对话框时设置 AlertifyJS 回调

javascript - 有人可以帮助修复我的 Alertify JS 代码吗?

javascript - Knockout JS : Observable Array not updating, 无法确定原因

javascript - 动态添加子元素的事件监听器也标记为父元素

javascript - CSS 悬停更改未悬停的元素

jquery - Alertify JS-更改提示对话框上的按钮文本

javascript - React v16.5.2 - 之后无条件屏幕刷新引发弹出消息

javascript - 使用 Alterifyjs 库创建具有不同形式的多个自定义对话框

javascript - 我应该如何将输出从分钟转换为 HH :MM format?

javascript - 仅在事件调用时加载 iframe