Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:13:45+00:00 2026-05-26T23:13:45+00:00

Problem: I have a confirmation box which pops up whenever I click on the

  • 0

Problem:

I have a confirmation box which pops up whenever I click on the save button. It saves the data fine when I click on OK. But when I click on cancel it does not cancel changes. It saves them instead. Could you please help me solve this issue:

Here is the JavaScript for it:

/
<asp:Button ID="view_btn_save" Text="Save" ValidationGroup="view" OnClick="view_btn_save_click"
                        OnClientClick="Validate_view()" runat="server"
                        />                        
                </td>
                <script type="text/javascript">
                    function Validate_view() {
                        var value = document.getElementById('<%=view_txt_name.ClientID%>').value;
                        var value2 = document.getElementById('<%=view_txt_title.ClientID%>').value;
                        var value3 = document.getElementById('<%=view_txt_description.ClientID%>').value;
                        var value4 = document.getElementById('<%=view_txt_pixelwidth.ClientID%>').value;
                        var value5 = document.getElementById('<%=view_txt_pixelheight.ClientID%>').value;

                        if (value == '' || value2 == '' || value3 == '' || value4 == '' || value5 == '') {
                            return alert('Please enter the missing fields');
                        }                        
                        else {
                            return confirm('Confirm changes?');
                        }
                    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:13:45+00:00Added an answer on May 26, 2026 at 11:13 pm

    You need to add a return statement to the OnClientClick declaration:

    OnClientClick="return Validate_view();"
    

    In the case where you show an alert, I would change your code to this:

    alert("...");
    return false;
    

    EDIT: Here’s a full example

    <script type="text/javascript"> 
        function Validate_view() { 
            var value = document.getElementById('<%=view_txt_name.ClientID%>').value; 
            var value2 = document.getElementById('<%=view_txt_title.ClientID%>').value; 
            var value3 = document.getElementById('<%=view_txt_description.ClientID%>').value; 
            var value4 = document.getElementById('<%=view_txt_pixelwidth.ClientID%>').value; 
            var value5 = document.getElementById('<%=view_txt_pixelheight.ClientID%>').value; 
    
            if (value == '' || value2 == '' || value3 == '' || value4 == '' || value5 == '') { 
                alert('Please enter the missing fields'); 
                return false;
            }                         
            else { 
                return confirm('Confirm changes?'); 
            } 
        } 
    </script>
    <asp:Button ID="view_btn_save" runat="server" Text="Save" OnClientClick="return Validate_view()" OnClick="view_btn_save_click" />                         
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem I have timestamped data, which I need to search based on the timestamp
i have an confirmation box where user can select OK to continue or Cancel
Problem: I have an address field from an Access database which has been converted
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: I have a web page. When I fill in the data and hit
I have a problem in creating an AJAX-based form submission which if its response
I have one LinkButton that I want to stop post-back on confirmation. But the
I have a slight problem with my confirmation. What happened before I included a
I have problem with querying webservice which uses WS-Security. I use code creadted by
Problem: We have a web app that calls some web services asynchronously (from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.