JSFiddle - React, Tailwind, and code Playground

by Dedi Wibisono

HTML

<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div>
        <input type='radio' id='alaamt_1' name='type' value='1' /> alamat 1
        </div>
        <div>
        <input type='radio' id='alamat_2' name='type' value='2' /> alamat 2  
        </div>
        
        <div>
        <input type='radio' id='alamat_3' name='type' value='3' /> alamat 3
        </div>
        
        <button class="btn btn-secondary" id="cek">
        Submit
        </button>
      </div>
     
    </div>
  </div>
</div>

CSS

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}

JavaScript

$("#cek").click(()=>{
	let checked = $("input[name$='type']:checked");
  let checkedVal = checked.val();
  let valid = 0;
  
    console.log(checkedVal)
  
   if (valid != checked.length) {
      //   alert(checkedVal);
      //localStorage.setItem("alamat", checkedVal);
      alert(checkedVal)
  } else {
      alert('silahkan isi dulu')
  }
  
})