How to validate if at least one of multiple input fields is entered?

后端 未结 2 1470
遇见更好的自我
遇见更好的自我 2020-12-07 03:05

I have a form with 3 fields, and submit button. when button clicked, if none is entered in 3 fields, throw validation message. If any one of the 3 fields are entered process

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 03:46

    At least for iceFaces another approach to validate across multiple fields, especially when the validation is more complex than just "required", is to use application level validation inside your backing bean.

    @see Custom Validator in Backing Beans

    • Add the validator attribute to you rcomponent and point it to teh validation method in your backing bean
    • inside teh backing bean you can now access all form fields and do cross validation

    Regards

    Rob

提交回复
热议问题