Show JavaScript Confirmation Message in Red Color

Last Reply 3 months ago By pandeyism

Posted 3 months ago

how to show confirmation message in red colour using javascript

Posted 3 months ago
Hi @amar,
Please try the following

Show JavaScript Alert Message when using AJAX UpdatePanel in ASP.Net

It might help you.

Cheers Andrea.

Posted 3 months ago
You may try this code to solve your issue:

<html>
<head> <meta charset="utf-8" /> <title>JavaScript String fontcolor() Method</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery- ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <script> $(function() { $( "#dialog-message" ).dialog({ modal: true, buttons: { Ok: function() { $( this ).dialog( "close" ); } }}); }); </script> </head> <body> <div id="dialog-message" title="My Dialog Alternative"> <p style='color:red'> Hello world </p> </div> </body> </html>

Posted 3 months ago

Hey amar,

You can't do anything with the alert/confirm boxes. If you need to style them then you need to use jQuery Modal dialog.

Please refer below sample.

HTML

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
    rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(function () {
        $("#dialog").dialog({
            buttons: {
                No: function () {
                    $("[id*=Button1]").click();
                },
                Yes: function () {
                    $(this).dialog('close');
                }
            }
        });
    });
    function Click() {
        alert("button is clicked.");
    }
</script>
<div id="dialog" style="display: none; color: red" title="Confirmation Message">
    Did You want to close.
</div>
<input type="button" id="Button1" value="Button" style="display: none" onclick="Click();" />

Demo