Forums

Forums / Developing Portals / Validate if radio button is checked

Validate if radio button is checked

Thread is closed for posting
3 posts, 1 answered
  1. Missing user
    Missing user avatar
    13 Apr 2015
    Link to this post
    Hi Clinton,
    When we try and check if a radio button is selected (either Yes or No), we continue to get FALSE value even when none of the options are selected. I understand it's considering no-value as FALSE. But is there a way to differentiate this?

    We need to keep both options unselected by default, and put a mandatory check on same if user is not selecting any. Please advise.

    Thanks,
    Vamsi.
  2. Clinton Bale
    Clinton Bale avatar
    126 posts
    Registered:
    21 Feb 2014
    Answered
    13 Apr 2015 in reply to Missing user
    Link to this post
    Hello,

    You can differentiate it by calling the get_checked method:

    var c = $find($(".CrmBoolean").attr("id"));
    var notChecked = c.get_trueControl().get_checked() === false && c.get_falseControl().get_checked() === false;
    	

    The notChecked variable will be a boolean value that contains whether or not the radio buttons are both not checked.
  3. Missing user
    Missing user avatar
    13 Apr 2015
    Link to this post
    Thanks Clinton. I'll give a try and let you know.

    Thanks,
    Vamsi.
3 posts, 1 answered