2

This issue may be linked to this post, in which case I think the bug wasn't fully fixed...but hopefully it's more simple than that...

I have the example below - a basic input form using HTML5 error messages for required fields. It works fine without a re-render - if you click save and the Salutation picklist is blank, you get the HTML5 required field message.

But if I add a re-render to the command button, the HTML messages stop working for the salutation picklist field - instead I get an error message below the field ("Error: You must enter a value") which is a bit jarring to the user.

On the actual page, I am using jQuery so I use that in the flow - but wondering if there is a syntax change that will make the HTML validation work with re-render?

<apex:page StandardController="Contact" showHeader="FALSE" sidebar="FALSE" standardStylesheets="FALSE" docType="html-5.0" cache="FALSE" >

    <apex:form id="action">
        <apex:outputPanel id="supporter">
            <label>Prefix</label>
            <apex:inputField required="true" id="nmSalutationf" label="Prefix" value="{!contact.salutation}" type="auto" styleclass="form-control input-sm"/>

            <label>First Name</label>
            <apex:inputField required="true"  id="nmFirstnamef" label="First Name" value="{!contact.FirstName}" type="text" styleclass="form-control input-sm"/>

            <label>Last Name</label>
            <apex:inputField required="true"  id="nmLastnamef" label="Last Name" value="{!contact.LastName}" type="text" styleclass="form-control input-sm"/>

            <label>Email Address</label>
            <apex:inputField required="true" id="ciEmailf" label="Email" type="email" value="{!contact.Email}" styleclass="form-control input-sm"/>

            <apex:commandButton action="{!save}" id="refreshbutton" value="Save" />
        </apex:outputPanel>

        <apex:outputPanel id="matchedo">
            Test 1
        </apex:outputPanel>

    </apex:form>
</apex:page>

If I change the commandButton line to this:

<apex:commandButton action="{!save}" id="refreshbutton" value="Save" reRender="supporter,matchedo"/>

The HTML5 Required message stops working, and instead I get a different standard error message below the field, which is not the experience I am looking for.

  • Try sticking immediate="true" on the button to see if that fixes the problem – Boris Bachovski Apr 15 '16 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.