Select a radio option and then click the same option again to submit the form

I have a question relating to using radio to submit a form, but only if an option is selected and thenthe same option is clicked again. The purpose is to allow the user to select from a range of radio options, and then confirm their choice by clicking their preferred option again, triggering the form to submit. I have tried many ways to achieve this, but I’m not even close. Any guidance hugely appreciated.

Add Comment
2 Answer(s)

According to your problem, On select radio saving that reference in hidden field. May be this could help you

document.getElementById('hidden').value="";      function check(val){         if( document.getElementById('hidden').value === val){             alert('submit');         }else{                 document.getElementById('hidden').value = val           alert(val);         }      }
<!DOCTYPE html> <html> <body> <h4>First Select and click the selected option to sumit</h4>    <input type="radio" name="option" value="Option1"  onclick="check(this.value)"> Option1<br>   <input type="radio" name="option" value="Option2"  onclick="check(this.value)"> Option2<br>   <input type="radio" name="option" value="Option3" onclick="check(this.value)"> Option3 <br/> Choosed Option<input type="text" value="" id="hidden">  </body> </html>

Add Comment

Please use this

make your button

 input type="submit" 

to

input type="button" 

or

in click event function write this code:

$("#your-form-id").submit(function(ev){ev.preventDefault();}); 
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.