mirror of https://github.com/layui/layui
fix(form): form.val 获取 multiple select 值错误 (#2425)
* fix(form): form.val 获取 multiple select 值错误 * fix(form): 表单验证时非字符串值不应规范化 * updatepull/2428/head^2
parent
e1aef65c4f
commit
d833771d77
|
@ -24,7 +24,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||||
// 内置的验证规则
|
// 内置的验证规则
|
||||||
verify: {
|
verify: {
|
||||||
required: function(value) {
|
required: function(value) {
|
||||||
if (!/[\S]+/.test(value)) {
|
if (!/[\S]+/.test(value) || value === undefined || value === null) {
|
||||||
return '必填项不能为空';
|
return '必填项不能为空';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -154,7 +154,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(/^(checkbox|radio)$/.test(item.type) && !item.checked) return; // 复选框和单选框未选中,不记录字段
|
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;
|
return field;
|
||||||
|
@ -1148,7 +1148,8 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||||
var verifyStr = othis.attr('lay-verify') || '';
|
var verifyStr = othis.attr('lay-verify') || '';
|
||||||
var vers = verifyStr.split('|');
|
var vers = verifyStr.split('|');
|
||||||
var verType = othis.attr('lay-vertype'); // 提示方式
|
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); // 移除警示样式
|
othis.removeClass(DANGER); // 移除警示样式
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue