fix(form): form.val 获取 multiple select 值错误 (#2425)

* fix(form): form.val 获取 multiple select 值错误

* fix(form): 表单验证时非字符串值不应规范化

* update
pull/2428/head^2
morning-star 2024-12-25 16:42:58 +08:00 committed by GitHub
parent e1aef65c4f
commit d833771d77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 3 deletions

View File

@ -24,7 +24,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
// 内置的验证规则
verify: {
required: function(value) {
if (!/[\S]+/.test(value)) {
if (!/[\S]+/.test(value) || value === undefined || value === null) {
return '必填项不能为空';
}
},
@ -154,7 +154,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
}
if(/^(checkbox|radio)$/.test(item.type) && !item.checked) return; // 复选框和单选框未选中,不记录字段
field[init_name || item.name] = item.value;
field[init_name || item.name] = othis.val();
});
return field;
@ -1148,7 +1148,8 @@ layui.define(['lay', 'layer', 'util'], function(exports){
var verifyStr = othis.attr('lay-verify') || '';
var vers = verifyStr.split('|');
var verType = othis.attr('lay-vertype'); // 提示方式
var value = $.trim(othis.val());
var value = othis.val();
value = typeof value === 'string' ? $.trim(value) : value;
othis.removeClass(DANGER); // 移除警示样式