Can you provide me with the Regular Expression that can be used to validate Decimal Values ranging from 0 to 99999.00

I need a regular expression in AngularJS to verify that a decimal number falls within the range of 0 and 99999.00, with up to 2 decimal places. Instead of using the max attribute in AngularJS, I want to utilize ng-pattern. I have tested various regex patterns but none have met all the criteria. For example:

  • 0 - valid
  • 0.0 - valid
  • 0.00 - valid
  • 0.000 - invalid
  • 1445.02 - valid
  • -34.39 - invalid
  • 59999.99 - valid
  • 99999 - valid
  • 99999.0 - valid
  • 99999.00 - valid
  • 99999.01 - invalid
  • 99999.99 - invalid

Answer №1

Here is a solution that should do the trick:

^((?:(?!7{6})\d{1,6}(?:\.\d{1,3})?)|(?:7{6}(?:\.00?)?))$

In simpler terms, this regular expression ensures that the number does not consist of 777777, then matches a 6 digit number with an optional decimal part. If that doesn't match, it looks for 777777, optionally followed by .0 or .00.

Check out the Demo here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Experience the seamless transition of new CSS animations

I designed a basic HTML game where a moving box disappears when clicked on. However, the animation that follows does not originate from the click location but rather from the original position. I believe the remove @keyframes at 0% should be based on the ...

What is a simple way to hide the menu when the user clicks anywhere on the screen?

I've encountered an issue with my code that involves the following functionalities: 1: When a user clicks a button, it toggles the drop-down menu on or off. 2: Clicking anywhere within the webslides element should close the menu if it's displayed ...

What does the "done" callback function entail in Node.js?

Many npm packages commonly utilize a "done" callback function in their code. I find it challenging to grasp its purpose. For instance: passport.serializeUser(function(user, done) { done(null, user.id); }); From what I can gather: The "done" function a ...

"Troubleshooting issues with the Updater function within the variable context API in React Native

I am in need of assistance as I am currently developing a survey system. The challenges I face involve creating surveys with an undetermined number of questions, requiring dynamic rendering based on the type of question (select, text, numeric, etc.). To ad ...

The AdminLTE Bootstrap Table Search Bar vanishes when extra <th> tags are added

Currently facing difficulties with the table functionality in AdminLTE. By default, AdminLTE includes a search and organization feature in its table structure. When I insert some table data using PHP, everything looks fine. However, when I attempt to add ...

Having trouble accessing the POST RESPONSE json in ReactJS and NodeJS

I have set up my own API server that is connected to a MySQL database. Whenever I send a request to the server, everything seems fine. I can see the input from the browser and the output from the database in the console. However, I am unable to see any new ...

Add the slide number and total count in between the navigation arrows of the owl carousel

In my Angular application, I am utilizing an ngx owl carousel with specific configurations set up as follows: const carouselOptions = { items: 1, dots: false, nav: true, navText: ['<div class='nav-btn prev-slide'></div>' ...

Struggling to style a nested table using CSS

Please take a look at this JSFiddle example for reference. I am currently working with tablesort and its associated CSS to achieve alternating row colors for the rows containing first and last names. Additionally, I want the rows within the sub-table disp ...

Inserting a Specific Iframe into a Designated Location in HTML with the Help of Jquery

Currently, I am encountering an issue with placing a dynamically created iframe inside a specific section of my webpage. The iframe is supposed to be contained within a div element named "maps", but instead it is appearing at the bottom of the page.This ma ...

Issue with Visual Studio Code and Chrome Debugger regarding unconfirmed breakpoint

Apologies if this question has been asked before, but I've gone through the existing answers and still can't find a solution. I am currently working on an older AngularJS application that has been partially migrated to Typescript. The source fil ...

Turn off error notifications from eslint parsing

Within my code, there is a conditional export that looks like this: if (process.env.NODE_ENV === 'testing') export myFunc; While in es6, this type of statement is typically not allowed due to the requirement for imports and exports to be top- ...

The specified timeout elapsed without the jasmine async callback being invoked

Having recently ventured into Protractor and javascript, I've encountered a persistent error that none of the existing solutions seem to shed light on. The issue revolves around understanding async callbacks within my Page Object model implementation. ...

Guide to displaying an error message upon form submission in AngularJS

When the form is submitted, I want to display the required error message. However, I am unsure how to achieve this with the current setup. Here is what I have attempted: <div class="controls"> <form name="formx" > <ul class ...

At what point are routed components initialized?

Here is a route setup I am working with: path: ':id', component: ViewBookPageComponent }, After adding this route, an error keeps popping up: Error: Cannot read property 'id' of null I haven't included a null check in the compo ...

Oops! The requested page "/api/auth/[...nextauth]" is missing the necessary "generateStaticParams()" function, thus making it incompatible with the "output: export" configuration

Currently, I am working on a Next.js project where I have successfully implemented user authentication using next-auth with the Google Provider. However, while attempting to build the project, an error is being thrown by the compiler stating: "Error: Page ...

Encountering an issue with the combination of SockJS and AngularJS: Error message

Currently experimenting with Angularjs and sockjs, utilizing this helpful resource: https://github.com/bendrucker/angular-sockjs On page load, I aim to transmit data via sockjs, however, encountering an Error: INVALID_STATE_ERR on the client side when att ...

Vue component failing to display data passed as props

As a Vue beginner, I ventured into creating a custom component and attempted to bind everything just like in the basic Vue CLI template. Here is my code snippet. Circle.vue <template> <div :style="custom"> </div> </template&g ...

Starting your React application with the `npm start` command

After creating my react app using the create-react-app command, I named it react-app. These were the steps I followed: Navigate to the directory by typing cd react-app/ Run the command npm start Encountered an error message that reads; npm ERR! Missing ...

Using Radio Buttons in a jqGrid Interface

Currently, I am attempting to integrate radio buttons within a jqGrid framework. I am aware that a custom formatter can be utilized for this purpose. Below is my code snippet, however, it fails to provide information on which radio button is selected or if ...

Ways to rearrange div elements using JavaScript

I need assistance with reordering div elements using JavaScript, as I am unsure of how to accomplish this task. Specifically, I have two divs implemented in HTML, and I would like the div with id="navigation" to appear after the div with class="row subhea ...