Solved

How to replace confirm dialog box OK/Cancel with YES/NO in Javascript

Posted on 2012-12-27
6
6,995 Views
Last Modified: 2013-01-02
How do I  replace confirm dialog box OK/Cancel with YES/NO in Javascript?

<asp:TextBox ID="plateQty" runat="server" Width="50px" onblur="validate(this)" maxlength="2" CssClass="TRAStext" Text='<%#Container.DataItem("qty")%>'></asp:TextBox>

function validate(_this) {
            if (_this.value >= "5") {
                //alert(_this.value);
                var retVal = confirm("Are you sure you want to order " + _this.value + " boxes?");
                if (retVal == true) {
                    return true;
                }
                else {
                    _this.value = "";
                    _this.focus();
                    return false;
                }
            }
        }
0
Comment
Question by:Meinhoonaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:honestman31
ID: 38724041
You cannot do that with the native confirm() as it is of browser's method.
you  will need to use usejQuery UI

More info ( and source )

http://stackoverflow.com/questions/11046572/make-javascript-alert-yes-no-instead-of-ok-cancel

http://stackoverflow.com/questions/823790/javascript-confirm-popup-yes-no-button-instead-of-ok-and-cancel
0
 
LVL 10

Expert Comment

by:honestman31
ID: 38724072
also please check this

http://dev.sencha.com/deploy/ext-4.0.0/examples/message-box/msg-box.html

it will be great help for you , just copy and paste the  code u want
don't forget to copy this file to your server msg-box.js
0
 

Author Comment

by:Meinhoonaa
ID: 38731237
I am looking for solution not mere links which I can find myself.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:honestman31
ID: 38732923
this  http://dev.sencha.com/deploy/ext-4.0.0/examples/message-box/msg-box.html   has the solution , just choose what you want and copy and paste the code ,

P.S. to view the source code  use  CTR + U
0
 
LVL 10

Accepted Solution

by:
honestman31 earned 500 total points
ID: 38733923
Here is a fully working code , I hope that what you want

<!doctype html>
 
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>jQuery UI Dialog - Modal confirmation</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <script>
    $(function() {
        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height:140,
            modal: true,
            buttons: {
                "YES": function() {
                    $( this ).dialog( "close" );
                },
                "NO": function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });
    </script>
</head>
<body>
 
<div id="dialog-confirm" title="Are you sure ?">
    
</div>
 

 
 
</body>
</html>

Open in new window


source
http://jqueryui.com/dialog/#modal-confirmation
0
 

Author Closing Comment

by:Meinhoonaa
ID: 38737996
thank you
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Debugging Html 8 32
Html split(text) Part2 6 22
null, truthy, falsey confusion 25 31
ASP.net Moving Visual Studio 2015 project to 2017 2 38
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question