Highlight an inputText in JSF when a validation error occurs

后端 未结 1 576
眼角桃花
眼角桃花 2020-12-29 13:21

I have a form with a lot of inputText, what I want is to highlight those who are not being filled with correct data.

I tried to use \'component.valid\' but it always

相关标签:
1条回答
  • 2020-12-29 13:58

    You should use component.valid instead of nom.valid.

    component is an implicit EL object for the current input component. And component.valid calls the isValid() method of the server side component. The id argument cannot be used this way.

    So you should change your code as follows:

    style="#{ component.valid ? 'border-color:black;' : 'border-color:red;'}"
    

    (Not related but you should better use style classes instead of hard coded styles. The valid check works for the styleClass attribute as well).

    0 讨论(0)
提交回复
热议问题