You need to sign in to do that
Don't have an account?
shan raz
how to make text field required when Reject Checkbox is checked
Hi
Hope everyone is healthy and safe.
I have 2 checkboxes, Accept or Reject
1 comment box
If user selects Reject checkbox and its true then Comments need to be Required.
I place this code in
<apex:inputTextarea value="{!accWrap.comments}" id="cmmts" required="{!IF(!accWrap.rejected==true, true, false)}" />
but it makes it required for everything, even when user selects accept and for all records.
Please see my code below and assist. thank you
Hope everyone is healthy and safe.
I have 2 checkboxes, Accept or Reject
1 comment box
If user selects Reject checkbox and its true then Comments need to be Required.
I place this code in
<apex:inputTextarea value="{!accWrap.comments}" id="cmmts" required="{!IF(!accWrap.rejected==true, true, false)}" />
but it makes it required for everything, even when user selects accept and for all records.
Please see my code below and assist. thank you
<apex:page controller="ZCQController" sidebar="false" docType="html-5.0" lightningStylesheets="true"> <script type="text/javascript"> function selectAllCheckboxes(obj,receivedInputID){ var inputCheckBox = document.getElementsByTagName("input"); for(var i=0; i<inputCheckBox.length; i++){ if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){ inputCheckBox[i].checked = obj.checked; } } } </script> <script> function confirmDisbaled(ifchecked, id1 ,id2) { document.getElementById(id1).disabled = ifchecked; document.getElementById(id2).disabled = ifchecked; } </script> <apex:form > <apex:pageBlock > <apex:pageBlockSection title="All Pending Quotes" collapsible="false" columns="2"> <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Quotes" > <apex:column value="{!accWrap.acc.Name}" /> <apex:column value="{!accWrap.acc.Quote_Status__c}" /> <apex:column value="{!accWrap.acc.Quote_Number__c}" /> <apex:column headerValue="Approve"> <apex:inputCheckbox value="{!accWrap.approved}" id="inputId2" onchange="return confirmDisbaled(this.checked, '{!$Component.inputId3}');"/> </apex:column> <apex:column headerValue="Reject"> <apex:inputCheckbox value="{!accWrap.rejected}" id="inputId3" onchange="return confirmDisbaled(this.checked, '{!$Component.inputId2}');"/> </apex:column> <apex:column headerValue="Comments"> <apex:inputTextarea value="{!accWrap.comments}" id="cmmts" required="{!IF(!accWrap.rejected==true, true, false)}" /> </apex:column> </apex:pageBlockTable> <apex:pageBlockTable value="{!att}" var="a" id="table2" title="All Associated Attachments"> <apex:column headerValue="Download"> <apex:outputLink value="{!URLFOR($Action.Attachment.Download, a.Id)}" target="_blank">View</apex:outputLink> </apex:column> <apex:column value="{!a.Parent.Name}" headerValue="Quote Number"/> <apex:column value="{!a.Name}" headerValue="File Name"/> <apex:column value="{!a.LastModifiedDate}"/> </apex:pageBlockTable> </apex:pageblockSection> <apex:pageblockSection > <apex:commandButton value="Save" action="{!save}" /> </apex:pageblockSection> </apex:pageBlock> </apex:form> </apex:page>
Are you setting 'rejected' as false anywhere in your controller or wrapper class?
Can you please look at this example https://www.salesforcetutorial.com/wrapper-class-for-displaying-the-selected-records/ and compare the boolean variable in the wrapper class with your controller?
Anudeep
For Reject scenario, call a new JS method and there make the Comment section required. Similar to confirmDisbaled() method
Please check and let me know if it works.
Regards,
Surojit ,