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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:03:38+00:00 2026-06-14T07:03:38+00:00

I have written a bunch of code to have a valid entry for Spend

  • 0

I have written a bunch of code to have a valid entry for Spend amount (32.4554, 234,324.34, etc.). I have additionally written code to limit the user from entering more than 13 digits (excluding . and ,).

All of this works perfectly in Firefox. But in IE 8, after the number of digits exceeds 13, if a letter is entered, Internet Explorer hangs and crashes! While debugging I noticed it faulting at the regex line, but the same regex works fine until that limit of 13 isn’t crossed! Regexperts, please! Show me the light!

function isIncorrectSpend(cubeCurrencySpend) {  
    if(!(/^([1-9]*[0-9]*,?[0-9]*)* (\.[0-9]*)?$/.test(cubeCurrencySpend))) {
        return true;
    }
    return false;
}

function isLongerThanThirteenDigits(cubeCurrencySpend) {
    cubeCurrencySpend = cubeCurrencySpend.replace(/,/g, "").replace(/\./g, "");
    if(cubeCurrencySpend.length>12) { 
        return true;
    }
    return false;
}

jQuery("input#minval").keyup( function() {
    if(isIncorrectSpend(jQuery("input#minval").val())) {
        jQuery("input#minval").val("");
        alert("please enter correct spend value");
    }        
});
jQuery("input#minval").keypress( function(e) {
    var code = (e.keyCode ? e.keyCode : e.which);
    if(isLongerThanThirteenDigits(jQuery("input#minval").val()) && (code > 47 && code < 58)) {
        alert("Please enter a number less than 13 digits");
        return false;
    }
    return true;
});
  • 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-14T07:03:42+00:00Added an answer on June 14, 2026 at 7:03 am

    I am quite sure this is a case of catastrophic backtracking. Your regex has too many possibilities to check, till it can fail.

    The problem is this part

    ([1-9]*[0-9]*,?[0-9]*)*
    

    and I am quite sure it is not doing what you expect it to.

    This will match the same stuff, but will fail much quicker:

    /^[1-9]*[0-9,]*(\.[0-9]+)?$/
    

    it is still allowing stuff like 1,,,,,,,.123, but much better than yours. If you want to disallow such things, you need to clarify your requirements.

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

Sidebar

Related Questions

I have a bunch of old VB.NET code, written originally on VS2005, and now
We have written a bunch of Java code and need to package this code
I have a bunch of code that's already written which currently relies on images
I have written this code inside a servlet to delete certain records from three
I have written this code in JavaScript and works perfectly fine when I include
I have a bunch of CSS written that makes my site target Mobile first,
Suppose you have got a bunch of files written in C, C++ or Fortran,
I have the expression already written, but whenever I run the code I get
I have written a Google App Engine application that programatically generates a bunch of
I've been given a bunch of messy code and a short time limit (no

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.