/    Sign up×
Community /Pin to ProfileBookmark

Validating numbers to the tenths place

What I want to do is set up an input box so that on blur it checks to see if the number within it is acurate only to the tenths place. I’m wondering if there’s some nifty trick in JS set up already to do that or do I need to jam out all the logic myself?

In case it wasn’t clear the first time:
99.9 = good
99.99 = bad
99.999 = bad
99.9999 = bad
etc.

Thank you.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorJun 11.2008 — accurate? Relative to [I]what[/I]?
Copy linkTweet thisAlerts:
@tenmilesauthorJun 11.2008 — I want to yell at the user if they input a number that is accurate to more than the tenths place. So accurate to the hundredths place would mean #.##. The database isn't setup to handle values that're more specific than to the tenths place so I want to keep the user from being allowed to put those kinds of numbers in.
Copy linkTweet thisAlerts:
@KorJun 11.2008 — Aha. You may use regular expressions for that:

http://lawrence.ecorp.net/inet/samples/regexp-intro.php
Copy linkTweet thisAlerts:
@tenmilesauthorJun 11.2008 — Just what I needed. Thank you very much.
×

Success!

Help @tenmiles spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...