如何删除alertify提示符下的取消按钮?

时间:2018-01-18 16:08:04

标签: alertifyjs

<SCRIPT LANGUAGE='JavaScript'>
                alertify.prompt('Please enter password for authorization', function(evt, value) {
                    value = md5(value);
                    if (value != null && value == '$pass') {
                                    alertify
                          .alert('Success! Shifting to Happy Hour. ', function(){
                            alertify.message(window.location = `main_2.php`);
                          });   
                }else{
                    alertify
                          .alert('Invalid Password, Please Try Again.', function(){
                            alertify.message(window.history.back());
                          });


                }});


            </SCRIPT>");

我想提示只输入文本输入和确定按钮。最简单的方法是什么?

1 个答案:

答案 0 :(得分:0)

最简单的方法是隐藏“取消”按钮。我添加了CSS以隐藏“取消”按钮。

alertify.prompt('Please enter password for authorization', function(evt, value) {
                    value = md5(value);
                    if (value != null && value == '$pass') {
                                    alertify
                          .alert('Success! Shifting to Happy Hour. ', function(){
                            alertify.message(window.location = `main_2.php`);
                          });   
                }else{
                    alertify
                          .alert('Invalid Password, Please Try Again.', function(){
                            alertify.message(window.history.back());
                          });


                }});
.ajs-cancel {
  display: none;
}
<script src='https://cdnjs.cloudflare.com/ajax/libs/AlertifyJS/1.11.1/alertify.min.js'></script>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/AlertifyJS/1.11.1/css/alertify.min.css'>