Jquery Radio Button Script
Simple jquery script, which helps to get confirmation when the radio button is clicked.
Features
- Script to find if radio button is selected or not.
- Responsive and easy to integrate.
- Get confirmation alert while selecting the radio buttons.
- Validation and check box for radio button improves user interaction in webpage.
Preview
Downloads
Code
<!--Script by hscripts.com-->
<html>
<head>
<title>Jquery Radio Button Script | Radio Button Confirmation </title>
<script type='text/javascript'>
$(document).ready(function() {
$('.chkrad').attr('checked', false);var selectedVal = "";
$("input:radio[name=test]").click(function(){
var selected = $("input:radio[name=test]:checked");
if (selected.length > 0) {
selectedVal = selected.val();
if (selectedVal=='yes') {
var cnfrm = confirm('Are you sure want to reload the page?');
if (cnfrm == true) {location.reload();}
else{alert("Thank You!");}
}
else if (selectedVal=='no') {
alert("Thanks for visiting this script!!");
}}
});var sds = document.getElementById("dum");
if(sds == null){
alert("You are using a free package.\n You are not allowed to remove the tag.\n");
$(".main").hide();
}var sdss = document.getElementById("dumdiv");
if(sdss == null){
alert("You are using a free package.\n You are not allowed to remove the tag.\n");
$(".main").hide();
}
});
</script>
</head>
<body>
<div align='center'>
<b>Click radio button to view confirmation message</b><br><br>
<div class='main'>
Reload Page :
<input type="radio" id="radioSelect" name="test" value="yes" class='chkrad' /> Yes <input type="radio" id="radioSelect" name="test" value="no" class='chkrad' /> No<br><br>
</div>
<div id="dumdiv" align="center" style=" font-size: 10px;color: #dadada;">
<a id="dum" style="padding-right:0px; text-decoration:none;color: green;text-align:center;" href="http://www.hscripts.com">©h</a>
</div>
</div>
</body>
</html>
- Release Date - 16-06-2015
- Get free version without ©copyright link for just $10/-
- For customization of this script or any script development, mail to support@hscripts.com
Usage
- Copy and paste the above code in your HTML page.
- Once after clicking the radio button you will get the confirmation alert.
- The variable "cnfrm" stores and displays the confirmation alert.
- For example, var cnfrm = confirm('Are you sure want to reload the page?');
License
- This Jquery code is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Detailed License information can be found here.
- You can purchase the script if your requirements does not meet our GPL License terms.
Related Scripts