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

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
Accepted answer

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...

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.

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?

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.

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

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.

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'.

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?

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 Champion Oct 07, 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. ;)

Think I will do, thanks!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 16, 2018 in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

1,289 views 17 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you