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
Vigneshwaran LoganathanVigneshwaran Loganathan 

hi frnz.

How to make apex:inputfile as required?

i have used the following code,

<apex:inputFile value="{!objAttachment1.body}" filename="{!objAttachment1.name}" required="true">
</apex:inputFile>

It dint workout. Any help on how to achieve this?

Thanks.

 

SeanCenoSeanCeno
Try wrapping it in an <apex: outputPanel> tag
 
<apex: outputPanel styleClass="requiredInput"/>
     <apex:inputField value="{!objAttachment1.body}" filename="{!objAttachment1.name}" required="true" />
</apex:outputPanel>

 
yvk431yvk431
If you are using a custom controller , try this way

<apex:page controller="documentExt">
    <apex:pageMessages />
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >                
                <apex:inputFile value="{!d.body}" fileName="{!d.Name}" required="true"/>
                <apex:commandButton value="Save" action="{!Save}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>

</apex:page>

--yvk