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 7730071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:07:51+00:00 2026-06-01T06:07:51+00:00

I have a code block that checks certain elements before allowing a form to

  • 0

I have a code block that checks certain elements before allowing a form to submit, the loop loops through OK.

I would anticipate, or at least had hoped that the first time it finds a problem, an alert is shown and then execution stops. What is actually happening is that alerts show multiple times, right down to the last one, and only the last one actually returns false!

I don’t understand why this is, what am I doing wrong? The JavaScript is below.

$('#deliverInForm').submit(function(){
    $('.childRow').each(function(){
        if($(this).find('.thisBinName').val()!='' || $(this).find('.unitQty').val()!=''){
            if($(this).find('.thisBinName').val()==''){
                alert('You have entered a quantity but no Bin, please correct and try again!');
                return false;
            }else if($(this).find('.unitQty').val()==''){
                alert('You have entered a Bin but no quantity, please correct and try again!');
                return false;
            }else if($(this).find('.unitQty').val()==0){
                alert('Can\'t move zero units into a bay, please correct and try again!');
                return false;
            }else if($(this).find('.unitQty').val()<0){
                alert('Can\'t deliver in minus units into a bay, please correct and try again!');
                return false;
            }
        }
    });

    if($('#supDocNo').val()==''){
        alert('Can\'t leave Supplier Reference blank, please correct and try again!');
        return false;
    }
    return true;
});
  • 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-01T06:07:52+00:00Added an answer on June 1, 2026 at 6:07 am

    make your function take an event argument, then call event.preventDefault()

    e.g.

    $('#deliverInForm').submit(function(event){
    $('.childRow').each(function(){
        if($(this).find('.thisBinName').val()!='' || $(this).find('.unitQty').val()!=''){
            if($(this).find('.thisBinName').val()==''){
                alert('You have entered a quantity but no Bin, please correct and try again!');
                event.preventDefault();
                return false;
            }else if($(this).find('.unitQty').val()==''){
                alert('You have entered a Bin but no quantity, please correct and try again!');
                event.preventDefault();
                return false;
            }else if($(this).find('.unitQty').val()==0){
                alert('Can\'t move zero units into a bay, please correct and try again!');
                event.preventDefault();
                return false;
            }else if($(this).find('.unitQty').val()<0){
                alert('Can\'t deliver in minus units into a bay, please correct and try again!');
                event.preventDefault();
                return false;
            }
        }
    });
    
    if($('#supDocNo').val()==''){
        alert('Can\'t leave Supplier Reference blank, please correct and try again!');
        event.preventDefault();
        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 have a small code block that should append text to the beg of
I have a block of code that works and I wanted to ask what
I have a block of code that basically intializes several classes, but they are
I have a block of code that is repeated within a DB2 stored procedure.
I have a block of code that serializes a type into a Html tag.
I have a block of code that works great in 32bit, and I'm trying
I have a block of code that worked outside of a function, but not
I have a code snippet written in PHP that pulls a block of text
Let's say that I have a block of code like this: keysPressed = new
We have have a block of code that generates a lot of exceptions (IndexOutOfRangeException

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.