You need to sign in to do that
Don't have an account?
Facebook
Required Mark for a input text field in a visualforce page
Hi,
How can i keep Required mark for an input text value in a visual force page?Setting required="true" is not working..
Name : <apex:inputtext value="{!ContactName}" id="name" required="true"/>
regards,
Abhi
Required="true" does not show any required mark it only show error message when filed is blank. You have to use an image that look like that and needs some coding also to show the Required Mark.
Secondly you can override the salesforce functionality. Find below a sample code as a workaround :
<apex:page controller="cls_con">
<apex:form>
<apex:pageBlock >
<div class = "requiredInput">
<div class = "requiredBlock"></div>
<apex:inputtext value="{!ContactName}" required="true"/>
</div>
</apex:pageBlock>
</apex:form>
</apex:page>
All Answers
do you mean the red line?
Try this:
Does that look any better?
Are you using a standard controller or custom controller. If you are using standard controller use <apex:inputfield/> component. You can also write a method in Apex controller to validate if the field has been filled or not before saving the record.
Required="true" does not show any required mark it only show error message when filed is blank. You have to use an image that look like that and needs some coding also to show the Required Mark.
Secondly you can override the salesforce functionality. Find below a sample code as a workaround :
<apex:page controller="cls_con">
<apex:form>
<apex:pageBlock >
<div class = "requiredInput">
<div class = "requiredBlock"></div>
<apex:inputtext value="{!ContactName}" required="true"/>
</div>
</apex:pageBlock>
</apex:form>
</apex:page>
It worked, thanks!
It's working, thanks