How to show confirm message with Yes and No button instead of Ok and Cancel button

Description



In javascript we usually show confirm message with this like code


var retVal = confirm(" Do you still want to Navigate ?");
return retVal;



If you click Ok button in cofirm message it will return true and if you click cancel it will return false.We can also replace Ok and Cancel with Yes and No.

Check Below code


<script language=javascript type="text/javascript">
function window.confirm(str)
{
execScript('n = msgbox("' + str + '","4132")', "vbscript");
return (n == 6);
}
function ShowConfirm()
{
if (confirm("Do you want to delete this item") == true)
{
return true;
}
else
{
return false;
}
}

function show()
{
var bAdd = ShowConfirm();
return bAdd;
}
</script>


Call the ShowConfirm() fuction onclick button


<asp:Button ID="BtnShow" runat="server" Text="Button" OnClientClick="return show();"/>

Note:It works only in IE


Thanks,
Abhay


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: