2016-01-22 29 views
3

我使用的是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; 
    } 
); 

我希望你能幫忙。

回答

1

的文檔顯示以下內容:

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。

+1

噢不錯!感謝它工作正常 –