locked
Modal or JavaScript for alert box on Web site? RRS feed

  • Question

  • User-373571878 posted

    Hello,

    I need a popup 'yes/no' box that will alert a user that a field was left blank. 

    "No Receipt file uploaded, was this your intention?'   Yes  -  No 

    So I need to check the value of a field, if blank I need to send this message option to the screen. 

    I had it working on my local machine with the use of a msgbox, but it does not work on the production web server.

    Should this be done in JavaScript, or does AJAX offer something I can use?

    Thank you

    Friday, April 1, 2016 2:59 PM

Answers

  • User-286291038 posted

    Hi,,

    Are you looking for something like this?

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 1, 2016 3:12 PM
  • User61956409 posted

    Hi Mike,

    yes sort of.  But I need to check the value of a field prior to displaying the message box.

    And if no or cancel is pressed, how can I stop the code behind from executing?

    You could refer to the follow sample code.

    <asp:Button ID="btncheck" runat="server" Text="Check" OnClientClick="return myfunction();" />
    <script>
        function myfunction() {
            var val = document.getElementById("element id").value;
            //your code
    
            if (confirm("No Receipt file uploaded, was this your intention?")) {
                //your code
                return true;
            } else {
                //your code 
                return false;
            }
        }
    </script>
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 5, 2016 7:04 AM

All replies

  • User-286291038 posted

    Hi,,

    Are you looking for something like this?

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 1, 2016 3:12 PM
  • User-373571878 posted

    yes sort of.  But I need to check the value of a field prior to displaying the message box.

    And if no or cancel is pressed, how can I stop the code behind from executing?

    thanks

    Friday, April 1, 2016 3:37 PM
  • User61956409 posted

    Hi Mike,

    yes sort of.  But I need to check the value of a field prior to displaying the message box.

    And if no or cancel is pressed, how can I stop the code behind from executing?

    You could refer to the follow sample code.

    <asp:Button ID="btncheck" runat="server" Text="Check" OnClientClick="return myfunction();" />
    <script>
        function myfunction() {
            var val = document.getElementById("element id").value;
            //your code
    
            if (confirm("No Receipt file uploaded, was this your intention?")) {
                //your code
                return true;
            } else {
                //your code 
                return false;
            }
        }
    </script>
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 5, 2016 7:04 AM