简体   繁体   中英

How to highlight a PrimeFaces textbox with red color border on required validation error?

I have a PrimeFaces textbox with autocomplete functionality. For required field validation error i have to show the error message and highlight the textbox with red color border. I have showed the error message with <h:message> how to highlight the textbox with red color border.

My textbox is mentioned below.

<p:focus context="accountNo">
                             <p:autoComplete id="accountNo" value="#{orderController.accountNo}"
                                  completeMethod="#{orderController.getAccountAutoComplete}"
                                  forceSelection="true"  styleClass="ui-inputfield" requiredMessage="Account number is required"  required="true"/>
                                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h:message for="accountNo"  style="color:red" />

                              </p:focus>

You can use <p:message> with for attribute set to id of textbox.

For example:

<p:inputText id="id" value="#{bean.idd}"     />
<p:message for="id" display="icon" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM