Hello,
The page is: http://adplus.ee/arendus/excellent2/kasutajatugi
I have need to check, that at least one of the checkboxes is cheked.
I tried for start information from this forum topic: http://www.chronoengine.com/forums/posts/f26/t66192/js-checkbox-validation-help.html?hilit=checkbox+validation, but it did not work.
I make some changes to the script:
Every checkbox have its own id and the script is adding class only for the first checkbox. Added class looks like
My javascript knowleage is very limited, but I need that functionality very much.
Jaak
The page is: http://adplus.ee/arendus/excellent2/kasutajatugi
I have need to check, that at least one of the checkboxes is cheked.
I tried for start information from this forum topic: http://www.chronoengine.com/forums/posts/f26/t66192/js-checkbox-validation-help.html?hilit=checkbox+validation, but it did not work.
I make some changes to the script:
window.addEvent('domready', function() {
$('checkbox_group12').addClass("validate['%countCheck']");
});
var countCheckMin = 1;
function countCheck(el){
var group = el.getSiblings(['input']);
group.include(el);
var count = 0;
group.each(function(item) {
if ( item.checked ) {
count++;
}
});
if ( count < countCheckMin ) {
el.errors.push("Palun vali vähemalt "+countCheckMin+" teema");
return false;
} else {
return true;
}
}
Every checkbox have its own id and the script is adding class only for the first checkbox. Added class looks like
class="A validate['%countCheck']"
..
My javascript knowleage is very limited, but I need that functionality very much.
Jaak
Hi jaak,
I suggest that you give all of the checkboxes the same array name e.g. kysymys[] and make the group required.
Bob
I suggest that you give all of the checkboxes the same array name e.g. kysymys[] and make the group required.
Bob
Hi Jaak,
1. Give all the checkboxes the same name kysymys[]
2. Add class='validate['group:1'] to each checkbox.
Bob
PS I noticed that at lease one of your checkboxes had a name with a special character in it - an ã perhaps - those are not permitted in HTML names, only a-z
1. Give all the checkboxes the same name kysymys[]
2. Add class='validate['group:1'] to each checkbox.
Bob
PS I noticed that at lease one of your checkboxes had a name with a special character in it - an ã perhaps - those are not permitted in HTML names, only a-z
Hi,
i am trying to create a validation on checkbox.
The user must choose at least one.
I don't anderstand the method.
First i creat 2 checkbox. (not a checkbox group).
With the same name ex : b1
With the same class ex : validate['group[b1]']
I have forgotten something i am sure.
I dont andstand your sentence above
Could you help me.
Regards
i am trying to create a validation on checkbox.
The user must choose at least one.
I don't anderstand the method.
First i creat 2 checkbox. (not a checkbox group).
With the same name ex : b1
With the same class ex : validate['group[b1]']
I have forgotten something i am sure.
I dont andstand your sentence above
make the group required.
Could you help me.
Regards
This topic is locked and no more replies can be posted.