How can I validate an input text box based on a selection from the drop-down list?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could pass the selected value of the dropdown as an attribute of the input component so that the validator can grab it.
E.g.
with
Note that the ordering of the components matters. JSF processes
UIInputcomponents in the order they appear in the view. If the dropdown component is placed after the input text component, then you need to pass#{menu.submittedValue}as attribute, but at that point the value is not converted yet. You could if necessary workaround with a<h:inputHidden>which is placed after the both components and put the validator in there.