Skip to content Skip to sidebar Skip to footer

How To Get Radio Button To Display Alert Message

I want to get a radio button to display an alert when it is selcted, so the user can check that they have chosen the correct value. This is the code I have for the radio buttons:

Solution 1:

You can do:

<inputtype="radio" name="level"id="GCSE" value="GCSE" onclick="alert('test');" />

Good luck!

Solution 2:

let's assume you have a form called # Myform

Then your code will be like this:

<form id="myForm">
<input type="radio" name="level"id="GCSE" value="GCSE" /> GCSE <br />
<input type="radio" name="level"id="AS" value="AS" /> AS <br />
<input type="radio" name="level"id="A2" value="A2" /> A2 <br />
</form>

Then, put in a tag script something like this:

<script>
$('#myForm input').on('change', function() {
   alert("Are you sure you have chosen the correct entry level? +"$('input[name=level]:checked', '#myForm').val()); 
});
</scritp>

Hope this works for you!

Thx

Post a Comment for "How To Get Radio Button To Display Alert Message"