You are viewing limited content. For full access, please sign in.

Question

Question

Dynamically Require Certain Table Fields when Radio Button is set to YES

asked on December 2, 2014

What is the syntax for the JavaScript in order to make this happen?

 

I essentially have a 2 option RadioButton (Yes/No) that when Yes is selected, I need to make certain Table fields required.

 

I've seen several post regarding check boxes, but not savvy enough yet to change it for radio buttons.

0 0

Answer

SELECTED ANSWER
replied on December 3, 2014 Show version history

Following are the JavaScript I used to set the for Column 1 as required when Yes is selected:

$(document).ready(function(){
  $('.radiocss input').change(function(){
    if($('.radiocss input[value="Yes"]:checked').length>0){
     var element=$('.target')[0];
     var columnid= element.getAttribute("data-col") 
      $('th#'+columnid+' label').append('<span class="cf-required">*</span>'); 
   $('.target input').attr('required', 'True'); 
    }
});
  
})

 

2 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.