Skip to content
Advertisement

How to check if number ends in .99

I’m attempting to do some validation a price field. I would like to check if the price entered into the price field ends in .99

I’ve attempted find posts about this but I can’t find examples for decimal numbers only whole numbers. I tried to check by doing price % 1 but it isnt consistent as the price increases by 10, 20 etc.

Is there a quick way to check if all numbers end in .99?

JavaScript

Advertisement

Answer

You can try regular expression as well. See following code for example:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement