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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:08:37+00:00 2026-06-14T21:08:37+00:00

i have a Invoice form and a jquery function. In Invoice if i enter

  • 0

i have a Invoice form and a jquery function.
In Invoice if i enter the quantity greater then the available quantity then i have to alert the user.

My problem is: Let the max quantity is 5, if i input data as 7 (single digit>max avail quantity) then my code is working fine. But if i enter two digigist number eg. 17(two digists>max avail quantity) then my alert box is not coming.
I mean onkeyup my function is working only with single digit.

How can i make it happening? Please help.

      $('input[name="quantity"]').keyup(function() 
       {  
    //problem is here
        var $tr = $(this).closest("tr");
        var unitprice = $tr.find('input[name^="unitprice"]').val();

        var q = $tr.find('input[name^="quantity"]').val();
        var cq = $tr.find('input[name^="checkquantity"]').val();

        if(q>cq)
      {
      alert("Error: Quantity value exceeds then available quantity..Max Quantity is "+cq);
          //this works fine only if single digit is entered in textbox quantity
       }

         //----below are some other stuffs -these are working fine
        $tr.find('input[name^="sprice"]').val($(this).val() * unitprice); 
        var totalPrice = 0;
        $('input[name="sprice"]').each(function()
        {
            totalPrice += parseFloat(this.value);
            $('[name=subtotal]').val(totalPrice);
        });  
    });  
    --------------
    ------------
   // Form containing the above textboxes
        <input type="submit" id="submitbtnId" value="Save"/>`
  • 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-14T21:08:38+00:00Added an answer on June 14, 2026 at 9:08 pm

    q > cq is comparing 2 strings, which is not what you want. You’re trying to compare the numerical value of those strings.

    Use this instead:

    if ( +q > +cq)
    {
        // alert your error
    }
    

    Note that by prefixing the variables with the + sign, you’re converting them to a number.


    Better yet, convert them to a number as soon as you get the values:

    var $tr = $(this).closest("tr");
    var unitprice = +$tr.find('input[name^="unitprice"]').val();
    
    var q = +$tr.find('input[name^="quantity"]').val();
    var cq = +$tr.find('input[name^="checkquantity"]').val();
    
    if ( q > cq )
    {
        alert("Error: Quantity value exceeds then available quantity..Max Quantity is " + cq);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form where a user can enter payments for an invoice. So...
I'm building an app in CodeIgniter. I have an invoice form which uses jQuery
I have a form that takes some input from a user and then gets
I have a simple form to enter details of a new case (kase), it's
I have a form for creating a new invoice with many items . class
I have two form inputs which display the calculated invoice sub-total and total of
I am creating a simple invoice system in access. I currently have a form
I have a nested form, like: <% form_for @invoice do |f| %> <%= render
I have an invoice model, that has many invoice items. I have a form
I have a form that has multiple entries to the same table, the problem

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.