How to check radio button is checked/selected or not by Javascript only?

You can validate the radio button in a form is selected or not with the help of javascript.

<div class="radio-buttons">
      <div class="male">
        <input class="form-radio" type="radio" name="gender" id="radio1" value="male">
        <label class="form-check-label" for="radio1">Male</label>

      <div class="female">
        <input class="form-radio" type="radio" name="gender" id="radio2" value="female">
        <label class="form-check-label" for="radio2">Female</label>

Here you can check it by document.querySelectorAll() with the help of attribute name,

var checkedInputRadio = document.querySelectorAll("input[name='gender']:checked");

if (checkedInputRadio.length) {
    var getRadioValue = checkedInputRadio[0].value;

Here, the checkedInputRadio variable fetches the checked result from the Form and if any input radio is selected, it will display the value of the selected radio button.

This is the simplest way to check and get the value of the selected input radio button.