Show JavaScript Confirmation Message in Red Color

Last Reply 5 months ago By pandeyism

Posted 5 months ago

how to show confirmation message in red colour using javascript

You are viewing reply posted by: pandeyism 5 months ago.
Posted 5 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