This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jun 23, 2011, 6:28 AM
26 Posts

Required Radio Button

  • Category: Dojo and Client Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 4
 Hi All,
 
I have a radio button group on my xPage and before saving it, I want to validate if any value has been selected on it or not. I tried a couple of options but could not succeed.  I also tried using separate Radio button and putting them in same group but could not figure out how to validate it.
 
Any guidance on this is much appreciated. 
 
Thanks 
Yusuf 
Jun 23, 2011, 9:26 AM
261 Posts
Re: Required Radio Button
Hi Yusuf,
 
Did you try attaching a validator to the radio button group?

A simple sample XPage:
 
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:messages id="messages1"></xp:messages>
   
    Name:&#160;<xp:inputText id="inputText1" required="true">
        <xp:this.validators>
            <xp:validateRequired message="Enter a name"></xp:validateRequired>
        </xp:this.validators></xp:inputText><br />
       
    Color:&#160;<xp:radioGroup id="radioGroup1">
        <xp:this.validators>
            <xp:validateRequired message="Select a color"></xp:validateRequired>
        </xp:this.validators>
        <xp:selectItem itemLabel="Blue" itemValue="blue"></xp:selectItem>
        <xp:selectItem itemLabel="Green" itemValue="green"></xp:selectItem>
    </xp:radioGroup>
    <br />
   
    <xp:button value="submit" id="button1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="complete">
        </xp:eventHandler></xp:button></xp:view>
 
Jun 23, 2011, 11:55 AM
26 Posts
Re: Required Radio Button
Hi Mark,
Thanks for your reply. I did try the radioGroup button with validator. I also tried the sample xpage that you suggested in the previous post and it is working mine. Below is the xpage that i was trying on and it is still not working for some reason. Can you please help me identify whats wrong in it.
 
xPage Sample: 
 <?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" >
 <xp:radioGroup id="radioGroup1" required="true">
  <xp:this.validators>
   <xp:validateRequired message="Select it"></xp:validateRequired>
  </xp:this.validators>
  <xp:selectItem itemLabel="1" itemValue="1"></xp:selectItem>
  <xp:selectItem itemLabel="2" itemValue="2"></xp:selectItem>
  <xp:selectItem itemLabel="3" itemValue="3"></xp:selectItem>
 </xp:radioGroup> 
 <xp:button value="Submit" id="button1">
  <xp:eventHandler event="onclick" submit="true"
   refreshMode="complete">
  </xp:eventHandler></xp:button></xp:view>
 
 
Thanks Again. 
Yusuf 
Jun 23, 2011, 2:25 PM
261 Posts
Re: Required Radio Button
Hi,
 
You're probably trying to do a clientside validation. My sample only works if you enable serverside validation
(Set: application properties --> XPages --> client validation to "Off").
 
You can read more about why clientside radio  button validation isn't working here: http://www.bleedyellow.com/blogs/andyc/entry/more_client_side_validation?lang=sv_se

Mark
Jun 24, 2011, 6:25 AM
26 Posts
Re: Required Radio Button
 Hi,
 
The application properties for my application is set to server default. So i guess the problem must be somewhere in the xpage that I have created. Will take a look at it again to figure out whts going on wrong.
 
Thanks again. :D 
 
Hope you have a nice error free day ;-) 
 
Yusuf. 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal