Remove 'none' value from radio button and limit number of selections

C Streic October 7, 2017

Hi,

I am currently looking for an option to remove the 'none' value from radio buttons, without setting the field as required. Alternatively I am looking for a solution to make two checkboxes behave like radio buttons (two options: 'yes' OR 'no'). 

The second question I have is, whether it is possible to limit the number of selections in a multi select list? I have a multi select list with 10 options, but a user should only be allowed to select 2 options out of 10.

 

Thank you!

3 answers

1 accepted

0 votes
Answer accepted
C Streic October 8, 2017

Ok, I found a way to transform two checkboxes into radio buttons, just in case somebody is interested:

 

If there is a customfield with two checkboxes on the create screen, the internal id of these checkboxes was customfield_xxxxx-1 and customfield_xxxxx-2. I then injected some JavaScript with the help of the PowerScripts Add on:

 

AJS.$("#customfield_xxxxx-1").change(function() {
$("#customfield_xxxxx-2").prop('checked', false);
});
AJS.$("#customfield_xxxxx-2").change(function() {
$("#customfield_xxxxx-1").prop('checked', false);
});

Seems strange, but works for me...

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 21, 2017

That's copying stuff with javascript - pretty much the wrong way to do anything.

I'm not going to knock it if it works for you.  But for anyone looking for the "right" answer, this is not really it.

C Streic October 24, 2017

Excuse me, I do not get your point here. It does exactly what I want it to do. I asked for a way to transform two checkboxes, it solved the problem. So far, no alternative solutions available.

What is "the right answer" in your opinion?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 25, 2017

Because you've converted them into the wrong form, and your javascript will only work in some places (and is likely to break on upgrade)

You should really go back to doing it properly.  Use the right sort of field with default and a mandatory flag.

C Streic October 26, 2017

Would like to do it as you suggest, but as I said before, I can not use the mandatory flag on fields I need to hide, depending on a selection a user makes. So there is no way around it.

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 7, 2017

If you don't offer "none", then how does a user set the value to "nothing"?  With no "none", you might as well default it and make it mandatory.

You can't natively restrict the number of selections, you need a little bit of code in validators or possibly something on-screen to do it.

C Streic October 8, 2017

The problem with making it mandatory is, that I can not hide the field with JJupin. That is why I am looking for an alternative. I want the users to select either 'yes' or 'no'.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 8, 2017

Then make sure it has options yes or no and make it mandatory.

What's the point of hiding it if you want to make them enter it?

C Streic October 8, 2017

Because I have different fields appearing on the create screen, depending on a selection a user makes at the beginning. I know, it is a bit complicated.

0 votes
Peter DeWitt
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 7, 2017

 

@C Streic,

Mandatory drop-down = no 'none' option. 

Non-mandatory drop-down = none option.

 

As far as the second part goes, try customizing the field description in the field configuration scheme to explain to the users that they should only select two options.  Hopefully they all read and follow. ;)

C Streic October 8, 2017

Think I will do, thanks!

Suggest an answer

Log in or Sign up to answer