0

In my program, the frontend is created using Primefaces. When creating the registration form, I put a checkbox, which is the acceptance of the terms of service. I would like the checkbox to turn red when clicking "Register" if this checkbox is not checked.

<p:selectBooleanCheckbox immediate="true" id="checkbox"
    value="#{backingBean.isChecked}"
    style="#{backingBean.isChecked ? 'background-color:red':'background-color:white'}">
</p:selectBooleanCheckbox>

In my baking bean, I have a private field isChecked that stores a boolean.

My first problem is that when I put in 'style' properties " background-color, the color changes also the area around the checkbox, not the border itself. Border-color also does not work.

My second problem is that when I click "Register", the checkbox does not change color.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
vaduzion
  • 1
  • 3
  • Does this answer your question? [JSF selectBooleanCheckbox required=true doesn't validate if checkbox is selected](https://stackoverflow.com/questions/14796961/jsf-selectbooleancheckbox-required-true-doesnt-validate-if-checkbox-is-selected) – Jasper de Vries Mar 22 '22 at 08:33
  • Just make it required and style based on the `ui-state-error` class. – Jasper de Vries Mar 22 '22 at 08:36

0 Answers0