Skip to content

Commit d56eb79

Browse files
committed
Fixed bug about checkbox when using an array for a name ie name="exm[]"
- Bug report and fix from Joshua(joshua.jack@gmail.com)
1 parent fe24a64 commit d56eb79

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

validetta-min.js

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

validetta.jquery.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name" : "validetta",
3-
"version" : "0.7.0",
3+
"version" : "0.8.0",
44
"title" : "Validetta - A tiny jquery plugin for validate your forms",
55
"description" : "Validetta is a tiny jQuery plugin which you can do client-side validation of your forms. It aims to decrease your burden with easy usage and flexible structure.",
66
"keywords" : ["validetta", "form", "forms", "jquery", "javascript", "validation", "validate"],
77
"homepage" : "http://lab.hasanaydogdu.com/validetta/",
88
"docs" : "http://lab.hasanaydogdu.com/validetta/",
99
"demo" : "http://lab.hasanaydogdu.com/validetta/#examples",
1010
"bugs" : "http://github.com/hsnayd/validetta/issues",
11-
"download" : "http://github.com/hsnayd/validetta/archive/v0.7.0.zip",
11+
"download" : "http://github.com/hsnayd/validetta/archive/v0.8.0.zip",
1212
"author" : {
1313
"name": "Hasan Aydoğdu",
1414
"url" : "http://github.com/hsnayd"

validetta.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Validetta - Client-side form validation jQuery plugin
3-
* Version: 0.7.0 (12 December 2013)
3+
* Version: 0.8.0 (13 December 2013)
44
* @jQuery Requires: v1.7 or above
55
* @Browser Support : ie8 or above, and all modern browsers
66
*
@@ -110,7 +110,7 @@
110110
// handle click event for checkboxes
111111
$( this.form ).find( '[data-validetta][type=checkbox]' ).on( 'click', function( e ){
112112
// fields to be controlled transferred to global variable
113-
fields = that.form.querySelectorAll( '[data-validetta][type=checkbox][name='+ this.name +']' );
113+
fields = that.form.querySelectorAll( '[data-validetta][type=checkbox][name="'+ this.name +'"]' );
114114
return that.init.call( that, e );
115115
});
116116
}
@@ -193,11 +193,11 @@
193193
}else if( rules[0] === 'maxChecked' && !that.check.checkbox.maxChecked.call( that, _el, rules[1] ) ){
194194
// Redirect to the first checkbox
195195
// I want to see the error message on the first element of checkbox group
196-
_el = that.form.querySelectorAll( 'input[type=checkbox][data-validetta][name='+ _el.name +']' )[0];
196+
_el = that.form.querySelectorAll( 'input[type=checkbox][data-validetta][name="'+ _el.name +'"]' )[0];
197197
_errors += messages.maxChecked.replace( '{count}', rules[1] )+'<br />';
198198
}else if( rules[0] === 'minChecked' && !that.check.checkbox.minChecked.call( that, _el, rules[1] ) ){
199199
// Redirect to the first checkbox
200-
_el = that.form.querySelectorAll( 'input[type=checkbox][data-validetta][name='+ _el.name +']' )[0];
200+
_el = that.form.querySelectorAll( 'input[type=checkbox][data-validetta][name="'+ _el.name +'"]' )[0];
201201
_errors += messages.minChecked.replace( '{count}', rules[1] )+'<br />';
202202
}else if( rules[0] === 'maxSelected' && !that.check.selectbox.maxSelected( _val, rules[1] ) ){
203203
_errors += messages.maxSelected.replace( '{count}', rules[1] )+'<br />';
@@ -256,7 +256,7 @@
256256
},
257257
// Equal check
258258
equal : function( val, arg ){
259-
return ( $( this.form ).find( 'input[name='+ arg +']' ).val() !== val ) ? false : true;
259+
return ( $( this.form ).find( 'input[name="'+ arg +'"]' ).val() !== val ) ? false : true;
260260
},
261261
/**
262262
* Credit Card Control
@@ -292,11 +292,11 @@
292292
return ( !_inp.checked ) ? false : true ;
293293
},
294294
maxChecked : function( _inp, arg ){
295-
var count = $( this.form.querySelectorAll( 'input[type=checkbox][name='+ _inp.name +']' ) ).filter( ':checked' ).length ;
295+
var count = $( this.form.querySelectorAll( 'input[type=checkbox][name="'+ _inp.name +'"]' ) ).filter( ':checked' ).length ;
296296
return ( count > arg ) ? false : true ;
297297
},
298298
minChecked : function( _inp, arg ){
299-
var count = $( this.form.querySelectorAll( 'input[type=checkbox][name='+ _inp.name +']' ) ).filter( ':checked' ).length ;
299+
var count = $( this.form.querySelectorAll( 'input[type=checkbox][name="'+ _inp.name +'"]' ) ).filter( ':checked' ).length ;
300300
return ( count < arg ) ? false : true ;
301301
}
302302
},
@@ -314,7 +314,7 @@
314314
},
315315
// Radio
316316
radio : function ( _inp ) {
317-
var count = $( this.form.querySelectorAll( 'input[type=radio][name='+ _inp.name +']' ) ).filter( ':checked' ).length ;
317+
var count = $( this.form.querySelectorAll( 'input[type=radio][name="'+ _inp.name +'"]' ) ).filter( ':checked' ).length ;
318318
return ( count === 1 ) ? false : true ;
319319
},
320320
// Custom reg check

0 commit comments

Comments
 (0)