我希望当用户尝试提交空表单时警报不会消失,相反它应该在同一警报中显示一些错误。我尝试执行 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{
}
});
最佳答案
你可以使用这个函数:
inputValidator: (value) => {
return !value && 'You need to write something!'
}
这将验证用户是否正在写入一个值。
关于javascript - SweetAlert 输入验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48155452/