gpt4 book ai didi

javascript - SweetAlert 输入验证

转载 作者:行者123 更新时间:2023-11-30 14:50:38 25 4
gpt4 key购买 nike

我希望当用户尝试提交空表单时警报不会消失,相反它应该在同一警报中显示一些错误。我尝试执行 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com