I want to make an inputText field's attribute required="true" on the VF page and display the error message : Error: You must enter a value (Note: I do not want to use an InputField here)
When I click on the submit button, this doesn't show me the inline error message.
Please see the below code, and can some one explain what am I doing wrong here?
<apex:page sidebar="false" showHeader="false" id="page" standardController="Case" extensions="MyControllerExt">
<div>
<apex:form styleClass="form-horizontal" id="form">
<div class="requiredInput">
<div class="requiredBlock"></div>
<apex:inputText value="{!myCustomVar}" id="LastName" label="LastName" required="true" />
</div>
<!-- Submit From -->
<apex:commandButton id="btn2" styleclass="btn btn-lg btn detail" rerender="form" value="Submit" action="{!submitAction}" />
</apex:form>
</div>
And this is what the document say about the required true attribute;
required -> Boolean -> A Boolean value that specifies whether this field is a required field. If set to true, the user must specify a value for this field. If not selected, this value defaults to false.
apex:pageMessages
, but should be rendering on the input itself as well.apex:inputField
; the error appears directly below the field, the input box gains a red outline.apex:inputText
, by contrast, only adds a message with a block. This is a different behavior between each element, and inputText is also not consistent with the salesforce UI.