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

  • Home
  • SEARCH
  • 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 8543787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:23:31+00:00 2026-06-11T12:23:31+00:00

I am using javascript for required field validation,i have used alert box,after clicking ok

  • 0

I am using javascript for required field validation,i have used alert box,after clicking ok in alert box then also controls goes to server side code for save click

function IsFieldEmpty() {
    var txtAgent_Name = document.getElementById("<%=txtAgent_Name.ClientID %>");

    if (txtAgent_Name.value == "") {
        alert('Please Enter Agent Name');
        txtAgent_Name.focus();
        return false;
    }
}
  • 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-06-11T12:23:32+00:00Added an answer on June 11, 2026 at 12:23 pm

    If the problem is that some event handler is still submitting data after showing an alert informing of a validation error, you’ll probably need to make the event handler function return false after showing the alert , in order to prevent further processing of the event.

    As pointed out by @Bergi in his comment, and if you’re using JQuery or another framework, you might need to use stopPropagation() or equivalent. See

    • How to stop event bubbling on checkbox click
    • event.preventDefault() vs. return false.

    UPDATE

    Seeing the code posted, it might be important to remark that the return false is being done inside the IsFieldEmpty function. That means that false is the return value for IsFieldEmpty. Take into account that if you’re submitting data in a similar way to this:

    <input type="submit" onclick="IsFieldEmpty()">
    

    IsFieldEmpty will return false but the event handler won’t. If it’s the case, you should change it to:

    <input type="submit" onclick="return IsFieldEmpty()">
    

    and make IsFieldEmpty return true when validations are passed.

    function IsFieldEmpty() {
        var txtAgent_Name = document.getElementById("<%=txtAgent_Name.ClientID %>");
    
        if (txtAgent_Name.value == "") {
            alert('Please Enter Agent Name');
            txtAgent_Name.focus();
            return false;
        }
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a form, where required field validation must have been checked. I
I'm using MVC3 with unobtrusive validation. I have a field that the user is
I have aspx page where only one text box will be a required field.
I have an issue in image validation using jQuery Or JavaScript. Please see code
I have a simple html form that I've added validation to using the JQuery
I have a function that contains messages for form field validation. However I would
I have a hidden field on a form that is created in Razor using
I am creating a JavaScript / ajax comment form using the jQuery Validation Plugin.
How can I execute some javascript when a Required Field Validator attached to a
I am using the jQuery Validation plugin and have an issue validating items that

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.