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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:10:00+00:00 2026-06-11T20:10:00+00:00

I have a form with many input=text and I have neraby two image (-,+)

  • 0

I have a form with many input=text and I have neraby two image (-,+) I want to increase or decrease the previous input text. I don’t want to put into the input text an id because I can have a lot of this line with input text and minus or plus.
With my code the minus button works but the plus button not why?

My jQuery code

$('.minus').click(function(){
        var intRegex = /^\d+$/;
        var floatRegex = /^((\d+(\.\d *)?)|((\d*\.)?\d+))$/;

        var num = $(this).prev('input').val();
        if(intRegex.test(num) || floatRegex.test(num)) {
            if (num>0){
                $(this).prev('input').val(num-1);
            }
        }
        else{
            //non è un numero
        }

    });

    $('.plus').click(function(){
        var intRegex = /^\d+$/;
        var floatRegex = /^((\d+(\.\d *)?)|((\d*\.)?\d+))$/;

        var num = $(this).prev.prev('input').val();
        if(intRegex.test(num) || floatRegex.test(num)) {
                $(this).prev.prev('input').val(num+1);
        }
        else{
            //non è un numero
        }

    });

HTML:

<input type="text" name="qta" id="qta" style="width:50px;"/>
                            <img src="img/shop/meno.jpg" alt="" class="minus" style="cursor:pointer"/>
                            <img src="img/shop/piu.png" alt="" class="plus" style="cursor:pointer"/>
  • 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-11T20:10:01+00:00Added an answer on June 11, 2026 at 8:10 pm
    var num = $(this).prev().prev('input').val();
    

    and

    $(this).prev().prev('input').val(num+1);
    

    You missed a () twice

    anyway I would wrap every input and images in their own wrapper and I would find the input with $(this).parent().find('input')

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form containing two text boxes for user input. Both text boxes
I want to submit a form that have many checkboxes with different values, using
I have my form elements here: <li><div id=formanswer1 class=clonedInput>Answer: <input type=text id=formanswer1 value= /></div></li>
I have a form with multiple text input fields and sub-forms. Is there a
I have the following form: <label>One</label> Product ID:<input type=text name=productid[] value=> Product Quantity: <input
I have an ASP.NET webpage that is rendering many (~3000) <input type=text> textboxes on
I have a DIV that contains many input text. I need a way in
I have a form on which user is adding text fields as many as
I have a form which (on a previous page) users can select how many
Have a form <div class=customer> <input type=text name=customer /> <input type=text name=address /> <select

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.