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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:05:08+00:00 2026-06-01T07:05:08+00:00

I have this form which allows the input of any product quantity from 1-10:

  • 0

I have this form which allows the input of any product quantity from 1-10:

<form method='post' action='cart.php'>
<input type='number' name='quantitychange' size='2' min='1' max='10' value=".$_SESSION["itemsSelected"][$i][1].">
<input type='hidden' name='ProductID' value=".$_SESSION["itemsSelected"][$i][0].">
<input type='submit' value='Update'>
</form>

And another form (button) to display a selection of payment modes:

<form action='cart.php' method='post'>
<input type='hidden' name='next'>
<input type='submit' value='Select Payment Mode'>
</form>

What I want to happen is that when a user did not input anything (1st form), ex. null or 0, I want to display an alert box that says ‘Product quantity can’t be null or 0’.

Here’s my code for that:

if (isset($_POST['next'])) {
if ($_POST['quantitychange']==null || $_POST['quantitychange']==0) {
?>
<script type='text/javascript'>
alert('Product quantity can't be null or 0.');
</script>
<?php
}
else {
echo "
//Payment modes here
";
}
}

The error is that even when a user inputs a quantity bet. 1 to 10, it still displays the alert message. Any help? Thank you.

By the way, the input type “number” only works in Google Chrome browser.

  • 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-01T07:05:08+00:00Added an answer on June 1, 2026 at 7:05 am

    Use a small javascript (or jQuery) function to validate the form before posting it. Have this function throw up the alert if your condition isn’t met and then return false. If the condition is met, return true, and it gets submitted.

    Edited to add since this might get googled, I’ll help a bit with code snippet I have used. The below example is jQuery and was used in production for a web application I made for my employees. document.form.doit.submit(); should be the pure javascript way of submitting the form.

    <script type="text/javascript">
    function subForm() {
        // document.form.doit.submit();
        if( test condition passes ) {
            $('#save_order').submit();
        }
    }
    </script>
    
    <form id="save_order" action="oms_db.php" method="POST">
    <input id="doit" type="button"
        value="i am a button" onClick="subForm();">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this input form which goes like this: <input type=checkbox name=vehicle value=Bike />
I have an input which is of this form: (((lady-in-water . 1.25) (snake .
I have a form which has two inputs. The first input allows a user
My form structure is like this in which fields[] input can be added any
I have this simple form which shows a pop up calendar when clicked on
I have this html form which has options: <tr> <td width=30 height=35><font size=3>*List:</td> <td
In my c# application i have this small form which is used to set
I have this form, in which i need to populate a combo box with
I have this form tag below where the form submits to itself which I
I have inserted this form with multiple checkbox items which collects some values, What

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.