+ Start a Discussion
dwwrightdwwright 

Possible to replicate normal field level validation on <apex:selectList>?

I have a VF page which contains (among other things) 3 picklists which are displayed using the <apex: selectList> component. The reason I'm doing this is because I need them to be dependant picklists, so I have code in my controller which dynamically updates their values.

 

All three of these fields are required; and this page is going to be displayed to external users on Sites, so the validation needs to be user friendly. Right now I'm having issues replicating the standard validation that accompanies inputField components. I've been able to copy the style to get the red bar to appear, but that's about it. The field is set to a default value of "--None--" since giving it a null value won't let the page render. This means that even if I put required="true" the fields will always have a value by default, which isn't very useful... What I want to be able to do is have a validation rule that these fields aren't equal to "--None--" and catch the exception the page throws to display an error message at the field level. Right now that works fine, but I can only display the error as a pageMessage. Is there a way to display these messages at the field level on selectList components?

Message Edited by dwwright on 03-14-2010 01:59 PM
Bhaskar525Bhaskar525

Dear friends,

                I am also facing the same problem. Please anyone help me how to show error at Field when using <apex:selectlist>.