Fixes #14901: Fixed trim validation for radio/checkbox button

This commit is contained in:
Evgeniy Moiseenko
2018-08-04 01:06:15 +03:00
committed by Alexander Makarov
parent 001e4c5aed
commit b36639b288
3 changed files with 10 additions and 3 deletions

View File

@ -236,9 +236,15 @@ yii.validation = (function ($) {
}
},
trim: function ($form, attribute, options) {
trim: function ($form, attribute, options, value) {
var $input = $form.find(attribute.input);
var value = $input.val();
var isCheckAble = $input.find('[type=radio]').is('[type=radio]') || $input.find('[type=checkbox]').is('[type=checkbox]');
if (!isCheckAble) {
return value;
}
value = $input.val();
if (!options.skipOnEmpty || !pub.isEmpty(value)) {
value = $.trim(value);
$input.val(value);