You need to sign in to do that
Don't have an account?
Bhaskar525
<apex:selectlist> field level validation
Hi friends,
i designed one application in that insted of multipicklist i used <apex:selectlist> tag to capture the information (for clientside view). i created one validation rule for that picklist using apex code.when validation occure it shows on the top of the page (apex:pagemessage). Is there any way to show at field level when validation occure.
You can try the following code :
<apex:outputpanel >
<apex:SelectList value="{!var}" >
<apex:selectOptions value="{!values}"></apex:selectOptions>
<apex:actionSupport event="onchange" action="{!someaction}" />
</apex:SelectList><br/>
<font color="red">
<apex:outputText id="errMsg" value="Enter a value" rendered="{!varError}"/>
</font>
</apex:outputpanel>
On submitting the form, catch the validation error in your controller and set the variable - varError to true.
All Answers
Hi,
In the Vf page display the validation error message on the field level for this you can create a string type property in the your controller and assign the error message in that property in catch block after that bind the property with the output label on the page below your Picklist and reRender output label on the command button link.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Dear Navatar,
If you don't mind could you please provide sample code how to validate. i didn't get how to work on it.
Thanks,
Bhaskar
You can try the following code :
<apex:outputpanel >
<apex:SelectList value="{!var}" >
<apex:selectOptions value="{!values}"></apex:selectOptions>
<apex:actionSupport event="onchange" action="{!someaction}" />
</apex:SelectList><br/>
<font color="red">
<apex:outputText id="errMsg" value="Enter a value" rendered="{!varError}"/>
</font>
</apex:outputpanel>
On submitting the form, catch the validation error in your controller and set the variable - varError to true.
Dear Dharshi,
Thanks for providing sample code. it give some idea to do my work.
Thanks,
Bhaskar.