Skip to content

Commit a721c9d

Browse files
committed
Validation required now also applies to inputs of type radio, issue victorjonsson#120
1 parent 6e32683 commit a721c9d

11 files changed

+33
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ of validation that should be applied.
301301
* Use a template for error messages when having errorMessagePosition set to top
302302
* Event onElementValidate added
303303
* Use the attribute data-validation-confirm to declare which input that should be confirmed when using validation=confirmation (issue #112)
304-
304+
* Validation "required" now supports inputs of type radio
305305

306306

307307
#### 2.1.47

form-validator/date.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#location-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.54
13+
* @version 2.1.55
1414
*/
1515
(function($) {
1616

form-validator/file.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.54
13+
* @version 2.1.55
1414
*/
1515
(function($, window) {
1616

form-validator/form-test.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,21 @@
120120
<input name="aplhanumeric only" class="form-control" name="test2" data-validation="alphanumeric" />
121121
</div>
122122

123-
<div class="checkbox">
123+
<div class="checkbox form-group">
124124
<label>
125125
<input name="checkbox" type="checkbox" data-validation="required" /> Must be checked
126126
</label>
127127
</div>
128128

129+
<div class="form-group">
130+
<label class="control-label">Must choose one</label>
131+
<br />
132+
<input name="radio" type="radio" data-validation="required" value="1" /> A
133+
<input name="radio" type="radio" value="1" /> B
134+
<input name="radio" type="radio" value="1" /> C
135+
<input name="radio" type="radio" value="1" /> D
136+
</div>
137+
129138
<div class="form-group">
130139
<label class="control-label">Even numbers only</label>
131140
<input name="even numbers" class="form-control" name="test4" data-validation="even_number" />

form-validator/html5.dev.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
* - validation when type="email"
99
* - validation when type="url"
1010
* - validation when type="time"
11+
* - validation when type="date"
1112
* - validation when type="number" and max="" min=""
1213
* - validation when pattern="REGEXP"
14+
* - validation when using maxlength
1315
* - Using datalist element for creating suggestions
1416
* - placeholders
1517
*
1618
* @website http://formvalidator.net/
1719
* @license Dual licensed under the MIT or GPL Version 2 licenses
18-
* @version 2.1.54
20+
* @version 2.1.55
1921
*/
2022
(function($, window) {
2123

form-validator/jquery.form-validator.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @website http://formvalidator.net/
77
* @license Dual licensed under the MIT or GPL Version 2 licenses
8-
* @version 2.1.54
8+
* @version 2.1.55
99
*/
1010
(function($) {
1111

@@ -1396,8 +1396,15 @@
13961396
*/
13971397
$.formUtils.addValidator({
13981398
name : 'required',
1399-
validatorFunction : function(val, $el) {
1400-
return $el.attr('type') == 'checkbox' ? $el.is(':checked') : $.trim(val) !== '';
1399+
validatorFunction : function(val, $el, config, language, $form) {
1400+
switch ( $el.attr('type') ) {
1401+
case 'checkbox':
1402+
return $el.is(':checked');
1403+
case 'radio':
1404+
return $form.find('input[name="'+$el.attr('name')+'"]').filter(':checked').length > 0;
1405+
default:
1406+
$.trim(val) !== '';
1407+
}
14011408
},
14021409
errorMessage : '',
14031410
errorMessageKey: 'requiredFields'

form-validator/jquery.form-validator.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/location.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#location-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.54
13+
* @version 2.1.55
1414
*/
1515
(function($) {
1616

form-validator/security.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @website http://formvalidator.net/#security-validators
1414
* @license Dual licensed under the MIT or GPL Version 2 licenses
15-
* @version 2.1.54
15+
* @version 2.1.55
1616
*/
1717
(function($) {
1818

form-validator/sweden.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @website http://formvalidator.net/#swedish-validators
1515
* @license Dual licensed under the MIT or GPL Version 2 licenses
16-
* @version 2.1.54
16+
* @version 2.1.55
1717
*/
1818
(function($, window) {
1919

form-validator/uk.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @website http://formvalidator.net/#uk-validators
1111
* @license Dual licensed under the MIT or GPL Version 2 licenses
12-
* @version 2.1.54
12+
* @version 2.1.55
1313
*/
1414
$.formUtils.addValidator({
1515
name : 'ukvatnumber',

0 commit comments

Comments
 (0)