You are viewing limited content. For full access, please sign in.

Question

Question

Is there a way to make checkbox default selections read only?

asked on May 2

Is there a way, maybe using JS, to set the default selections of a checkbox as read only in the modern forms designer?

I have a checkbox field with some defaults set and I want them 'set' so they cannot be unchecked but have the non-default selections available to be checked by the user. Is this possible?

0 0

Answer

SELECTED ANSWER
replied on May 2 Show version history

Hi Craig, this is a solutions using only CSS, maybe someone can give you a better way, but I love made simple. 

Field6 in the example I share with you is the value of the Checkbox I used for this example, you must find yours in your specific Checkbox where you want to apply this and replace the number 6 for you Field id number.  The other number's next to -0, -1, -4, according your image is the positions of your checkbox values, the first value always started with -0. 

/* Disable mouse interaction for the checkbox inputs */
#Field6-0,
#Field6-1,
#Field6-4 {
  pointer-events: none;   /* Prevents any mouse interaction */
  opacity: 0.6;           /* Gives a disabled/readonly visual appearance */
  cursor: not-allowed;    /* Shows a "not allowed" cursor on hover */
}

/* Disable mouse interaction for the associated labels */
label[for="Field6-0"],
label[for="Field6-1"],
label[for="Field6-4"] {
  pointer-events: none;   /* Prevents label click events */
  opacity: 0.6;           /* Matches the disabled input style */
  cursor: not-allowed;    /* Shows the same visual cursor */
}

I hope that can help you. 

1 0
replied on May 2

Luis, this worked perfectly.  Thanks for the solution!

1 0
replied on May 2

I'm so glad to know it's been helpful. I want to tell you that if the person filling out this information, instead of using the mouse or hovering over the screen to select, uses the Tab key on the keyboard to move between fields and presses the Space key, they're likely activating or deactivating the predefined selection. I'm looking for a solution for this using JavaScript. As soon as I have it, I'll share it with you. I have an idea, but for some reason, I can't get it to work to prevent this keyboard error.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.