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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:51:03+00:00 2026-05-31T04:51:03+00:00

Having a weird issue with jQuery/JavaScript. I’m using this code: var minimumPercent = $(‘.donationTextBox’).val();

  • 0

Having a weird issue with jQuery/JavaScript. I’m using this code:

var minimumPercent = $('.donationTextBox').val();

$('.donationTextBox').change(function() {
    var donationAmount = parseFloat($('.donationTextBox').val());
    donationAmount = donationAmount.toFixed(2);

    if(donationAmount < minimumPercent || donationAmount == "NaN") {
        $('.donationTextBox').val(minimumPercent);
    }
    else {
        $('.donationTextBox').val(donationAmount);
    }
});

This code I’ve written changes the value of an input box (text) so the value entered by the user is in money format (EG: 96.49) and also checks to make sure it isn’t lower than the amount in minimumPercent. If it is, then it’ll change the value to minimumPercent.
The problem I’m having is, say if minimumPercent holds 2.50 and the user inputs 100.00, for some strange reason it assumes that 100.00 is lower than 2.50. Although, 200.00 works fine.

Any ideas? Thanks for the help!

  • 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-31T04:51:04+00:00Added an answer on May 31, 2026 at 4:51 am

    Try ParseFloat when you set minimumPercent.

    var minimumPercent = ParseFloat($('.donationTextBox').val());
    

    I think the is engine is comparing a string to a float, thus converting your float back to a string and when you do that 100.00 < 2.50 = true do to the left to right alphabetical comparison.

    Mike

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

Sidebar

Related Questions

I've been having this weird issue with jQuery which came with Wordpress 3.2.1. I'm
I'm having this weird issue and I'm hoping someone could clear this up for
I'm having a bit of a weird issue here, basically, im using hibernate together
This is a really weird issue I'm having and I'm not really sure what
I am having this weird issue with Cruise Control crashing, when I add the
I'm having an odd issue in FF10 using jQuery 1.7.1. I have a gallery
I've been having this weird issue when trying to do a UI animation between
I'm having a weird issue with my jQuery Autocomplete. I have an autocomplete textbox
I'm having a weird issue - in my code I am fetching data from
Hello good morning everyone, i am having a weird issue when using imagePickerController. Actually

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.