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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:29:30+00:00 2026-05-30T06:29:30+00:00

I am trying to take this code and add one piece to it. I

  • 0

I am trying to take this code and add one piece to it. I would like the #total to have a maximum number. I am not even sure how to approach this one. I have looked around the query documentation at adding a validation or something but it wasn’t what I wanted. Any help would be greatly appreciated. http://jsfiddle.net/anderskitson/VVkzG/1/

JQUERY:

$('#the_input_id').keyup(function() {
    updateTotal();
});

$('#the_input_id1').keyup(function() {
    updateTotal();
});

var updateTotal = function() {
    var input1 = parseInt($('#the_input_id').val());
    var input2 = parseInt($('#the_input_id1').val());
    if (isNaN(input1) || isNaN(input2)) {
        $('#total').text('');
    } else {
        $('#total').text(input1 + input2);
    }
};​
  • 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-30T06:29:32+00:00Added an answer on May 30, 2026 at 6:29 am

    jsfiddle.net/VVkzG/2

    HTML

    <form method="post">
        <input type="text" id="the_input_id">
        <input type="text" id="the_input_id1">
    </form>
    
    </div>
    <div id="total">
    
    </div>​
    

    Javascript

    $('#the_input_id').keyup(function() {
        updateTotal();
    });
    
    $('#the_input_id1').keyup(function() {
        updateTotal();
    });
    
    var updateTotal = function() {
        var input1 = parseInt($('#the_input_id').val());
        var input2 = parseInt($('#the_input_id1').val());
        if (isNaN(input1) || isNaN(input2)) {
            $('#total').text('');
        } else {
            var max = 500;
            var total = input1 + input2;
    
            if(total > max) {
                $('#total').text('The maximum is '+max);
            } else {
                 $('#total').text(total);
            }
    
    
        }
    };​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm at a lose with this one. Trying to take edittext from a list
I am trying to take tables from one Access Database File, add them to
could anyone take a look at this for me? Problem: trying to output a
I have a datagridview with 9 columns. I am simply trying take the value
So I'm trying to take a bilinear interpolation algorithm for resizing images and add
I am trying to integrate some third party tracking code into one of my
I have this code to send variables to a datagrid on another page protected
I have a NSMutableArray of QuoteMap objects. When I add one using the below
I am trying to take favicons and add them to a dynamic image that
So I have some SMTP stuff in my code and I am trying to

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.