Skip to content

Commit

Permalink
Fixed bug about checkbox when using an array for a name ie name="exm[]"
Browse files Browse the repository at this point in the history
- Bug report and fix from Joshua(joshua.jack@gmail.com)
  • Loading branch information
hsnaydd committed Dec 13, 2013
1 parent fe24a64 commit d56eb79
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions validetta-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions validetta.jquery.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name" : "validetta",
"version" : "0.7.0",
"version" : "0.8.0",
"title" : "Validetta - A tiny jquery plugin for validate your forms",
"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.",
"keywords" : ["validetta", "form", "forms", "jquery", "javascript", "validation", "validate"],
"homepage" : "http://lab.hasanaydogdu.com/validetta/",
"docs" : "http://lab.hasanaydogdu.com/validetta/",
"demo" : "http://lab.hasanaydogdu.com/validetta/#examples",
"bugs" : "http://github.com/hsnayd/validetta/issues",
"download" : "http://github.com/hsnayd/validetta/archive/v0.7.0.zip",
"download" : "http://github.com/hsnayd/validetta/archive/v0.8.0.zip",
"author" : {
"name": "Hasan Aydoğdu",
"url" : "http://github.com/hsnayd"
Expand Down
16 changes: 8 additions & 8 deletions validetta.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Validetta - Client-side form validation jQuery plugin
* Version: 0.7.0 (12 December 2013)
* Version: 0.8.0 (13 December 2013)
* @jQuery Requires: v1.7 or above
* @Browser Support : ie8 or above, and all modern browsers
*
Expand Down Expand Up @@ -110,7 +110,7 @@
// handle click event for checkboxes
$( this.form ).find( '[data-validetta][type=checkbox]' ).on( 'click', function( e ){
// fields to be controlled transferred to global variable
fields = that.form.querySelectorAll( '[data-validetta][type=checkbox][name='+ this.name +']' );
fields = that.form.querySelectorAll( '[data-validetta][type=checkbox][name="'+ this.name +'"]' );
return that.init.call( that, e );
});
}
Expand Down Expand Up @@ -193,11 +193,11 @@
}else if( rules[0] === 'maxChecked' && !that.check.checkbox.maxChecked.call( that, _el, rules[1] ) ){
// Redirect to the first checkbox
// I want to see the error message on the first element of checkbox group
_el = that.form.querySelectorAll( 'input[type=checkbox][data-validetta][name='+ _el.name +']' )[0];
_el = that.form.querySelectorAll( 'input[type=checkbox][data-validetta][name="'+ _el.name +'"]' )[0];
_errors += messages.maxChecked.replace( '{count}', rules[1] )+'<br />';
}else if( rules[0] === 'minChecked' && !that.check.checkbox.minChecked.call( that, _el, rules[1] ) ){
// Redirect to the first checkbox
_el = that.form.querySelectorAll( 'input[type=checkbox][data-validetta][name='+ _el.name +']' )[0];
_el = that.form.querySelectorAll( 'input[type=checkbox][data-validetta][name="'+ _el.name +'"]' )[0];
_errors += messages.minChecked.replace( '{count}', rules[1] )+'<br />';
}else if( rules[0] === 'maxSelected' && !that.check.selectbox.maxSelected( _val, rules[1] ) ){
_errors += messages.maxSelected.replace( '{count}', rules[1] )+'<br />';
Expand Down Expand Up @@ -256,7 +256,7 @@
},
// Equal check
equal : function( val, arg ){
return ( $( this.form ).find( 'input[name='+ arg +']' ).val() !== val ) ? false : true;
return ( $( this.form ).find( 'input[name="'+ arg +'"]' ).val() !== val ) ? false : true;
},
/**
* Credit Card Control
Expand Down Expand Up @@ -292,11 +292,11 @@
return ( !_inp.checked ) ? false : true ;
},
maxChecked : function( _inp, arg ){
var count = $( this.form.querySelectorAll( 'input[type=checkbox][name='+ _inp.name +']' ) ).filter( ':checked' ).length ;
var count = $( this.form.querySelectorAll( 'input[type=checkbox][name="'+ _inp.name +'"]' ) ).filter( ':checked' ).length ;
return ( count > arg ) ? false : true ;
},
minChecked : function( _inp, arg ){
var count = $( this.form.querySelectorAll( 'input[type=checkbox][name='+ _inp.name +']' ) ).filter( ':checked' ).length ;
var count = $( this.form.querySelectorAll( 'input[type=checkbox][name="'+ _inp.name +'"]' ) ).filter( ':checked' ).length ;
return ( count < arg ) ? false : true ;
}
},
Expand All @@ -314,7 +314,7 @@
},
// Radio
radio : function ( _inp ) {
var count = $( this.form.querySelectorAll( 'input[type=radio][name='+ _inp.name +']' ) ).filter( ':checked' ).length ;
var count = $( this.form.querySelectorAll( 'input[type=radio][name="'+ _inp.name +'"]' ) ).filter( ':checked' ).length ;
return ( count === 1 ) ? false : true ;
},
// Custom reg check
Expand Down

0 comments on commit d56eb79

Please sign in to comment.