我希望警报在用户尝试提交空表单时不会消失,相反,它应该在同一警报中显示一些错误。
 有效的功能。我尝试查看文档,但找不到任何...

这是我的代码-

    swal({
     title:"Enter a Username",
     content: {
                element: "input",
                attributes: {
                    placeholder: "Type your username",
                    type: "text"
                     },
             },


    className: "mySwal"
    }).then((username)=>{
            //get the username
            if(username){

            }else{


            }

});

最佳答案

您可以使用此功能:

inputValidator: (value) => {
    return !value && 'You need to write something!'
  }


这将验证用户是否正在写入值。

10-04 22:09
查看更多