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


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;
return false;

function show()
var bAdd = ShowConfirm();
return bAdd;

Call the ShowConfirm() fuction onclick button

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

Note:It works only in IE


Article by Abhay Kumar Raut
DNS MVM and .Net Guru Team Lead at CirrusCloud Systems Bhubaneswar,Odisha Thanks and Regards, Abhay Kumar Raut

Follow Abhay Kumar Raut or read 39 articles authored by Abhay Kumar Raut


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: