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
coolkrishcoolkrish 

Visual force page conditional required

Hi,

I am  trying to make a field conditionally required in visual force page as below but it is not working:

<apex:inputfield value="{!Account.NPI_vod__c}" required="{!IF(Account.Credentials_vod__c= 'DO', true, false)}" />

Please advise.

Thanks,
Krishna.
Nithesh NNithesh N
Is it working... if you are giving just plain 'true' or 'false' ?
coolkrishcoolkrish
Yes Nitesh, if we give simple true or false...it is working....
Nithesh NNithesh N
I think, I know where is the issue...try using '==' instead of '='
<apex:inputfield value="{!Account.NPI_vod__c}" required="{!IF(Account.Credentials_vod__c == 'DO', true, false)}" />

Let me know if it works...

Best,
Nithesh
coolkrishcoolkrish
Thanks Nitesh but still no good after "==" change....
I even used controller to make it required.....but somehow required attribute getting stuck once it is set and not resetting...
I read in one of the posts that there is an issue with the required attribute to conditionally set it.
vijay mauryavijay maurya
I am at same page now. @coolkrish, how it worked please let me know although its too late to comment here.