+ Start a Discussion
uuuu 

Enable input file Field on VF page

Hello developers,
I need help.
If InputField in not null then enable InputFile apex tag on VF page.
How to do it.
Please help me.
Thanks in advance
Regards,
Anita sodhi
ANUTEJANUTEJ (Salesforce Developers) 
Hi Anita,

Can you elaborate the scenario? In case if you are searching for a way for validating the entered value in the input field in visualforce page you can check the below link for reference:

>> https://success.salesforce.com/answers?id=90630000000ZjhxAAC

I hope this helps.

Regards,
Anutej
ANUTEJANUTEJ (Salesforce Developers) 
I think you could try putting the file option in a div tag and rerender the div tag.

Additionally I found this below forum thread that could be of help.

>> https://developer.salesforce.com/forums/?id=906F0000000DBxTIAW
Dushyant SonwarDushyant Sonwar

You can disable the file input.

Just call js method on change event of textbox give class names to your text inputboxes and file inputbox.

var textvalue = document.getElementsByClassName("inputClass")[0].value;
if(textvalue == ''){
  document.getElementsByClassName("myFileClass")[0].disabled = true;

}
else{
document.getElementsByClassName("myFileClass")[0].disabled = false;

}
 


https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_fileupload_disabled2

Let us know if you have any trouble implementing it.