Validation Sweetalert2多输入验证
我试图在多模态中包含多个表单,正如我所读到的,我必须使用Validation Sweetalert2多输入验证,validation,input,sweetalert,sweetalert2,Validation,Input,Sweetalert,Sweetalert2,我试图在多模态中包含多个表单,正如我所读到的,我必须使用swal.mixin和queue,所有这些表单都包含多个输入 我已经做过了,但是找不到一种方法来验证所有这些表单,有什么建议吗 这是我的密码: swal.mixin({ confirmButtonText: 'Siguiente', buttonsStyling: false, }).queue([ { html: "<form class='formulario' a
swal.mixin
和queue,所有这些表单都包含多个输入
我已经做过了,但是找不到一种方法来验证所有这些表单,有什么建议吗
这是我的密码:
swal.mixin({
confirmButtonText: 'Siguiente',
buttonsStyling: false,
}).queue([
{
html:
"<form class='formulario' action='' method='post'>" +
"<div class='fila'>"+
"<img src='src/images/svg/icons/person.svg' class='imagen'/>"+
"<input id='name' class='espacio-datos' name='nombre' type='text' placeholder='Nombre' maxlength='20' required>" +
"</div>"+
"<div class='fila'>"+
"<img src='src/images/svg/icons/id.svg' class='imagen'/>"+
"<input id='ced' class='espacio-datos' name='num_ident' type='text' placeholder='Cedula' onkeypress='onlyNumbers(event)'>" +
"</div>"+
"<div class='fila'>"+
"<img src='src/images/svg/icons/phone.svg' class='imagen'/>"+
"<input id='tlf' class='espacio-datos' name='num_telef' type='text' placeholder='Telefono' onkeypress='onlyNumbers(event)'>" +
"</div>"+
"</form>",
preConfirm: function () {
var array = {
'nombre' : $("#name").val(),
'cedula' : $("#ced").val(),
'telefono' : $("#tlf").val(),
}
return array;
},
},
{
html:
"<form action='' method='post'>" +
"<div class='main-cont'>"+
"<span>" +
"Por favor ingresa el codigo de verificacion NUIP "+
"que hemos enviado a tu celular" +
"</span>"+
"<div class='row cuadros'>" +
"<input id='num-1' class='inp-num' data-pos='0' type='text' maxlength='1' name='one' onkeypress='isInputNumber(event)' autofocus='autofocus'/>" +
"<input id='num-2' class='inp-num' data-pos='1' type='text' maxlength='1' name='two' onkeypress='isInputNumber(event)'>" +
"<input id='num-3' class='inp-num' data-pos='2' type='text' maxlength='1' name='three' onkeypress='isInputNumber(event)'>" +
"<input id='num-4' class='inp-num' data-pos='3' type='text' maxlength='1' name='four' onkeypress='isInputNumber(event)'>" +
"</div>" +
"</div>"+
"</form>",
preConfirm: function () {
return [
$("#num-1").val(),
$("#num-2").val(),
$("#num-3").val(),
$("#num-4").val(),
];
},
}
swal.mixin({
confirmButtonText:“Siguiente”,
按钮样式:false,
}).排队([
{
html:
"" +
""+
""+
"" +
""+
""+
""+
"" +
""+
""+
""+
"" +
""+
"",
预确认:函数(){
变量数组={
'nombre':$(“#name”).val(),
'cedula':$(“#ced”).val(),
‘telefono’:$(“#tlf”).val(),
}
返回数组;
},
},
{
html:
"" +
""+
"" +
“赞成进行核查”+
“你的血是什么?”+
""+
"" +
"" +
"" +
"" +
"" +
"" +
""+
"",
预确认:功能(){
返回[
$(“#num-1”).val(),
$(“#num-2”).val(),
$(“#num-3”).val(),
$(“#num-4”).val(),
];
},
}
在sweetalert2上,如果没有定义任何输入,则不会调用inputValidator
函数
在您的情况下,一种解决方法是在mixin中添加输入
,然后使用onBeforeOpen将其隐藏
基本上,混合物变成:
swal.mixin({
confirmButtonText: 'Siguiente',
buttonsStyling: false,
input: 'text'
})
然后向队列数组中的每个元素添加以下代码以隐藏输入文本:
onBeforeOpen: function (dom) {
swal.getInput().style.display = 'none';
}
您可以在此处看到使用代码实现的方法:与其放置然后隐藏输入字段,不如在预确认
函数中调用Swal.showValidationMessage('Message')
。这样可以防止模式关闭。