c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
JavaScript

JavaScript Confirm submit button onClick

| | JavaScript

The JavaScript confirmation dialog box is used to handle user’s agreement on any option.Here, I will show you how to use a JavaScript alert confirm, it prompts a dialog box with two buttons OK and Cancel.

If the User click the ok button, the JavaScript window method will return true.  If we have written any server side coding for the button, that will perform in the operation. If the user clicks the Cancel button, the confirm button will return false.

HTML & JavaScript CODE:

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#btnSubmit").click(function () {
                var result = confirm("Areyou sure wants to continue ?");

                if (result == true) {
                    return true;
                }

               else {
                    return false;
                }
            });
        });
    </script><input id="btnSubmit" type="submit" value="submit" />