+ 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