function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
orikkerorikker 

Visualforce required field validation error message

I have two fieds on that page that are dynamically rendered on the page and if rendered they become required. When user hit save and the field is empty, there is no error message on the page or field that it is required, record does not get updated, but there is nothing indicating that..... Any ideas why?

EnthEnth

Need to see your page but first thing to check is that you have included <apex:pageMessages/> tag on your page otherwise the error won't render anywhere. Second lesson is how ugly the configuration error messages are in Visualforce :-)

orikkerorikker

I had the tag, problem was with it being refreshed on save... Long story short, I have a different issue now. When I switch field to yes, required fields show up, when I switch to no, those fields stay and it wont let me  save... ideas?

 

 

<apex:pageBlockSection collapsible="false" columns="1"
                        title="Closing Information" id="closingInfo">
                        <apex:pageBlockSectionItem >
                            <apex:outputLabel value="Does the member want to use a specific title company" />
                            <apex:inputfield value="{!cl.Member_want_to_use_specific_title_com__c}">
                                <apex:actionSupport event="onchange" rerender="closingInfo"     status="status" />

                                </apex:inputField>
                        </apex:pageBlockSectionItem>
                        <apex:inputField value="{!cl.Title_Company_Name__c}" rendered="{!cl.Member_want_to_use_specific_title_com__c == 'Yes'}" 
                                                    required="{!cl.Member_want_to_use_specific_title_com__c == 'Yes'}"/>
                        <apex:inputField value="{!cl.Title_Company_Phone__c}" rendered="{!cl.Member_want_to_use_specific_title_com__c == 'Yes'}"
                                                required="{!cl.Member_want_to_use_specific_title_com__c == 'Yes'}"/>
                        
                    </apex:pageBlockSection>

 

 

ministe2003ministe2003

I have this very problem.  There is a tag called ActionRegion which on the face of it looks like it'll fix this problem because it stops things being processed on ajax refresh.  Trouble is this means that it doesnt display or hide the field when the required condition changes so you just end up with a new problem!

I think I'm just going to remove all my "required" attributes and do the validation in code before saving the record.