This is a public Forum  publicRSS


    Bruno Aun
    Conditional Required Fields
    Topic posted August 2, 2017 by Bruno AunExplorer 
    148 Views, 5 Comments
    Conditional Required Fields

    Hi There,

    Here's the requirement I have in PSEUDO CODE

         Radiobutton is marked "YES"
         make Textbox required
    ELSE (marked as "NO")
         leave Textbox not required

    If this was plain Javascript or JQuery I could easily write it.
    I've searched for similar code online but couldn't find anything useful.

    So if anyone could provide any insight on how to go about this, it would be greatly appreciated

    Thanks in advance,



    • Pramod Vasudeva Murthy

      I would write a simple widget from the scratch and enable logic.js and do the following steps:

      • Since this is a radio button; subscribe for checked event
      • After that, you can either fire an even to make the textbox widget(custom of-course) to have required attribute
      • OR remove rn_Required class from that widget(It used to work in previous versions, not sure if it will work for existing)

      Here is a sample code:

      Radio button check:

      document.getElementsByName('<text_field>')[0].removeClass = "rn_Required";
      document.getElementsByName('<text_field>')[0].addClass = "rn_Required";


    • Bruno Aun

      Hi Pramod V,

      Thanks a lot for your input. I will give it a shot.


    • Lage Antony

      Hi Bruno,

      I am sure that Pramod code works. I am also posting how this can be achieved in YUI



  = true;






 = false;





      Lage Antony

    • Danette Beal

      Hi Bruno,

      Make sure to come back and let us know what you ended up doing.


      Danette, Community Manager

    • Bruno Aun

      Sorry for the lack of feedback

      I had to prioritize other project here, so I'll get back to this next week and I'll let you know what happens.

      I am more inclined to use plain JS then YUI, because I have zero experience with the latter

      Thanks anyways