JavaScript

JavaScript Confirm submit button onClick

JavaScript Confirm submit button onClick, someone asked me to explain?

jquery confirm example

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" />

 

Post your comments / questions