I have two radio buttons and a text area. Now what i want to do is,when i change the radio button when text area is not empty i need a corfirm box. Only if user clicks ok Then only the radio button must be changed .or else,the value in the text area must be shown and the value of radio button must not changed..
My code
jQuery
--------
$(".radio1").change(function(event){
if($(".txtarea").val() != "")
{
var flag = confirm("Do you want to change ?");
}
if(flag)
{
$(".txtarea").val("");
}
});
Html
------
<input type="radio" id="radio1" name="radio1" class="radio1">hello
<input type="radio" id="radio2" name="radio1" class="radio1">hi
<textarea id="txtarea" class="txtarea"></textarea>