我希望当用户尝试提交一个空表单时警报不会消失,而是应该在同一个警报中显示一些错误。我尝试执行 swal.showInputError("some error") 但它给出了一个错误,它不是有效的功能。我尝试查看文档,但找不到任何...
这是我的代码-
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{
}
});
Run Code Online (Sandbox Code Playgroud)
您可以使用此功能:
inputValidator: (value) => {
return !value && 'You need to write something!'
}
Run Code Online (Sandbox Code Playgroud)
这将验证用户是否正在写入值。
| 归档时间: |
|
| 查看次数: |
12459 次 |
| 最近记录: |