You need to sign in to do that
Don't have an account?
Semira@gmail.com
Make a field required when a checkbox is not checked through VF Page
Hi I have a visualforce page where I made a input check box. I wan't to make another field required when this checkbox is NOT checked.
Here's the part of VF code:
<apex:pageblockSection id="ProjectInfo2" title="Project Site Contact Information" collapsible="true" Columns="2">
<apex:inputField value="{!job.Project_Site_Contact_Name__c}"/>
<apex:inputCheckbox label="Same as caller" onclick="{!SameAsCaller}"/>
<apex:commandButton onclick="window.open('/apex/NewRecord','Popup','height=400,width=1000,left=100,top=100,scrollbars=yes,toolbar=no,status=no')" value="New Project Site Contact"/>
</apex:pageblockSection>
Now I want to use something like:
<apex:inputField value="{!job.Project_Site_Contact_Name__c}" required='{!IF((!SameAsCaller == 'false'), 0, 1)}'/>
However, this is saying I'm providing text instead of boolean value. Is this even possible, if so how?
Please HELP!
Here's the part of VF code:
<apex:pageblockSection id="ProjectInfo2" title="Project Site Contact Information" collapsible="true" Columns="2">
<apex:inputField value="{!job.Project_Site_Contact_Name__c}"/>
<apex:inputCheckbox label="Same as caller" onclick="{!SameAsCaller}"/>
<apex:commandButton onclick="window.open('/apex/NewRecord','Popup','height=400,width=1000,left=100,top=100,scrollbars=yes,toolbar=no,status=no')" value="New Project Site Contact"/>
</apex:pageblockSection>
Now I want to use something like:
<apex:inputField value="{!job.Project_Site_Contact_Name__c}" required='{!IF((!SameAsCaller == 'false'), 0, 1)}'/>
However, this is saying I'm providing text instead of boolean value. Is this even possible, if so how?
Please HELP!
What this says is "require the field when SameAsCaller is false". Alternatively, you could use required="{!NOT(SameAsCaller)}"
Hope this helps.
https://developer.salesforce.com/forums?id=906F000000096T8IAI
<apex:inputField value="{job.Project_Site_Contact_Name__c}" required="{!IF(SameAsCaller,'true'), true, false)}" />
Code solution: have an actionFunction that rerenders your required field when the checkbox is unchecked and shows the field/makes it required. This way you get the cleanest UI solution.
Code solution: When I put is action:{!SameAsCaller} and try to save it, it is asking to to create a method. I SameAsCaller is a boolean variable that's only taking the input whether it's true or not. How to get around it.