You need to sign in to do that
Don't have an account?
DineshGupta
How to make a radio button required ?
Hi,
I am working on force.com sites, for that I need to incorporate some radio buttons and those must be required fields.
So i coded like below,
<td align="center" width="10%" style="vertical-align:middle;text-align:center;">
<div>
<apex:outputPanel >
<div class="requiredInput">
<div class="requiredBlock"> </div>
<apex:selectRadio id="EQ2" onchange="renderPhyDet(this);" value="{!MemberEnrollment__c.Emp_Q2_Selected__c}">
<apex:selectOption itemValue="Yes" itemLabel="Yes"> </apex:selectOption>
<apex:selectOption itemValue="No" itemLabel="No"> </apex:selectOption>
</apex:selectRadio>
</div>
</apex:outputPanel>
</div>
</td>
Vertical line is showing but the page is not stopping the user if he dont select the radio button.
So I added required="true" label="Choose One" to the radio button, now the page is not being submitted even I submit the page. I think this "required" attribute is working but error message is not being displayed at the radio field which I have mentioned in the "label".
I am working on force.com sites, for that I need to incorporate some radio buttons and those must be required fields.
So i coded like below,
<td align="center" width="10%" style="vertical-align:middle;text-align:center;">
<div>
<apex:outputPanel >
<div class="requiredInput">
<div class="requiredBlock"> </div>
<apex:selectRadio id="EQ2" onchange="renderPhyDet(this);" value="{!MemberEnrollment__c.Emp_Q2_Selected__c}">
<apex:selectOption itemValue="Yes" itemLabel="Yes"> </apex:selectOption>
<apex:selectOption itemValue="No" itemLabel="No"> </apex:selectOption>
</apex:selectRadio>
</div>
</apex:outputPanel>
</div>
</td>
Vertical line is showing but the page is not stopping the user if he dont select the radio button.
So I added required="true" label="Choose One" to the radio button, now the page is not being submitted even I submit the page. I think this "required" attribute is working but error message is not being displayed at the radio field which I have mentioned in the "label".
I think you set the defalut value in the controller and it show the required line in the page but when you save without selecting the option so its by default save.
Thanks & Regards
Gyanender Singh
http://www.mirketa.com
Did you get the solution for it. i have the same problem which I'm unable to solve can you please let me know if you have idead
Hi sanjeev kakaraparthi,
I got the solution for it. All i did is I have added "<apex:pageMessages />" tag at the desired location along with the above code...
The code is like below,
<apex:pageMessages />
.. // Code //
.. // Code //
.. // Code //
.. // Code //
<div >
<apex:outputPanel >
<div class="requiredInput">
<div class="requiredBlock"> </div>
<apex:selectRadio id="EQ1" onchange="renderPhyDet(this);" value="{!MemberEnrollment__c.Emp_Q1_Selected__c}" required="true" label="Choose either YES or No for 1st health question">
<apex:selectOption itemValue="Yes" itemLabel="Yes" > </apex:selectOption>
<apex:selectOption itemValue="No" itemLabel="No" > </apex:selectOption>
</apex:selectRadio>
</div>
</apex:outputPanel>
</div>
Let me know if u still face the issue..
Regards,
Dinesh