Click here to Skip to main content
16,019,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i use Yes/No instead of OK/Cancel in javascript of pop up message box
Posted

No, you can't, at least not with "native" javascript boxes.

If you really, really want a yes/no popup than you will have to create a HTML/CSS dialog and display it in the DOM.

There are probably several people who have done this already, so try googling for a solution.
 
Share this answer
 
Go with jQuery plugins like https://jqueryui.com/dialog/[^]
 
Share this answer
 
Yes..u can..

Create your own confirm box:

XML
<div id="confirmBox">
    <div class="message"></div>
    <span class="yes">Yes</span>
    <span class="no">No</span>
</div>



Create your own confirm() method:

C#
function doConfirm(msg, yesFn, noFn)
{
    var confirmBox = $("#confirmBox");
    confirmBox.find(".message").text(msg);
    confirmBox.find(".yes,.no").unbind().click(function()
    {
        confirmBox.hide();
    });
    confirmBox.find(".yes").click(yesFn);
    confirmBox.find(".no").click(noFn);
    confirmBox.show();
}



Call it by your code:

C#
doConfirm("Are you sure?", function yes()
{
    form.submit();
}, function no()
{
    // do nothing
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900