Skip to content

Commit a503398

Browse files
author
bearyan
committed
优化 支持checkbox的reg是{0, x}的情况 Tencent#102
1 parent eae4d94 commit a503398

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/form/form.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
22
* Tencent is pleased to support the open source community by making WeUI.js available.
3-
*
3+
*
44
* Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
5-
*
5+
*
66
* Licensed under the MIT License (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
8-
*
8+
*
99
* http://opensource.org/licenses/MIT
10-
*
10+
*
1111
* Unless required by applicable law or agreed to in writing, software distributed under the License is
1212
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
1313
* either express or implied. See the License for the specific language governing permissions and
@@ -48,19 +48,17 @@ function _validate($input, $form, regexp){
4848
if(checkboxInput.checked) ++count;
4949
});
5050

51-
if(!count) return 'empty';
52-
5351
if(regs[1] === ''){ // {0,}
5452
if(count >= parseInt(regs[0])){
5553
return null;
5654
}else{
57-
return 'notMatch';
55+
return count == 0 ? 'empty' : 'notMatch';
5856
}
5957
}else{ // {0,2}
6058
if(parseInt(regs[0]) <= count && count <= parseInt(regs[1])){
6159
return null;
6260
}else{
63-
return 'notMatch';
61+
return count == 0 ? 'empty' : 'notMatch';
6462
}
6563
}
6664
}else{

0 commit comments

Comments
 (0)