1. renzo.rucco
  2. General
  3. Tuesday, July 08 2014, 11:56 AM
Hello,
I need to limit the maximum number of options chosen in a field of type CheckBoxList. For example in the attached image there are a number of options to choose: I would limit to a maximum of three choices. Is it possible?
Thanks a lot.
Renzo
Attachments (1)
admin Accepted Answer
Admin
Sorry, but Easy Profile not have this feature. We add this to our TODO list, is a great feature.;)

You may add some Javascript to do this.
Example (tested and work) add this javascript code to your template or script file
jQuery(document).ready(function($){
$('#jform_alias_of_field input').change(function(){
if($('#jform_alias_of_field input:checked').length==3)
{
$('#jform_alias_of_field input:not(:checked)').attr('disabled','disabled');
}
else
{
$('#jform_alias_of_field input').removeAttr('disabled');
}
});
});


if your field have alias "keywords" replace "jform_alias_of_field" with "jform_keywords"

With this when you have set 3 option, the function disable other options
  1. more than a month ago
  2. General
  3. # 1
renzo.rucco Accepted Answer
Exactly where i must insert this code? In the master template of my web site?
  1. more than a month ago
  2. General
  3. # 2
admin Accepted Answer
Admin
Yes, you can insert this into some js file of your template (at the end of file).

If you send me your site link I can tell you which file.

You can insert also into our js file /components/com_jsn/assets/js/name.js but if you update easy profile you lost the modification.
  1. more than a month ago
  2. General
  3. # 3
renzo.rucco Accepted Answer
There is another problem.
Suppose that during the first compilation of profile, we have select three options. Properly others are disabled. But if you return to the edit profile and add one new option, this to me is granted. I can even select them all and save. How can I avoid this problem?
Thanks
Renzo
  1. more than a month ago
  2. General
  3. # 4
admin Accepted Answer
Admin
ok,
try this code:
jQuery(document).ready(function($){
$('#jform_alias_of_field input').change(function(){
if($('#jform_alias_of_field input:checked').length==3)
{
$('#jform_alias_of_field input:not(:checked)').parent().css('opacity','0.6');

}
else if($('#jform_alias_of_field input:checked').length>3)
{
$(this).removeAttr('checked');
}
else
{
$('#jform_alias_of_field input:not(:checked)').parent().css('opacity','1');
}
});
$('#jform_alias_of_field input').change();
});


I have found another problem with chrome HTML5 validation.:D
  1. more than a month ago
  2. General
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.
Sorry, the discussion is currently locked. You will not be able to post a reply at the moment.