Numeric String Validator
Check whether text is a valid numeric string as you type it, right in your browser, without sending it anywhere.
Input
Output
No value
Guide
What is a numeric string?
A numeric string is text that holds a number: digits, perhaps with a plus or minus sign and a decimal part, such as 42, -7 or 3.75. Everything typed into a form arrives as text, and so does every value read from a CSV file, a spreadsheet export, a URL such as ?page=3 or a config file. Before a program adds, compares or stores such a value as a number, it checks that the text really holds one.
Codes made only of digits, such as PINs and order numbers, are numeric strings too. They often start with a zero that has to stay, so they're checked as text, not turned into numbers.
Tool description
Type or paste a value into the Numeric string field, and the result shows as you type: "Numeric string is valid" or "Numeric string is not valid". Spaces and line breaks around a pasted value are ignored, but a space inside the number makes it fail.
The Decimal separator menu sets the sign between the whole part and the decimals: Dot, Comma or Arabic decimal separator (٫). It starts on the separator most people type in the language you're reading the page in. Digits only starts off. Turn it on to accept nothing but digits, as codes such as PINs need: signs and separators then fail, whatever the menu says.
Numbers that pass
The examples use Dot. With Comma or the Arabic separator, that sign takes the dot's place: 3,75 or 3٫75.
- Digits with or without a plus or minus sign:
42,-7,+15 - Leading zeros:
007 - Decimals:
3.75,-0.5 - A separator with nothing before it:
.5,-.5 - Numbers of any length
Numbers that fail
- A separator with nothing after it:
5. - E notation and words:
1e5,Infinity,NaN - Thousands separators and spaces inside:
1,000,1 000 - Prefixes of other number systems:
0x1F,0o17 - With Digits only on, everything but digits:
-7,+15,3.75
Good to know
- The Arabic decimal separator goes with Western digits:
3٫14passes, while٣٫١٤, written in Arabic-Indic digits, fails. - The check knows no thousands separator. With Comma,
1,000passes as a number with three decimals. - Size doesn't count, so a long numeric string may still be too big for your program's number type.
- This check sits between two others. It accepts decimals, which the Integer Validator rejects, but not e notation or a separator at the end, which the Float Validator accepts.
Features
- Checks numbers with a sign, leading zeros and decimals
- Dot, comma or Arabic decimal separator
- A Digits only setting for codes such as PINs
- Results as you type, with no button to press
- Runs in your browser, so nothing you type is sent anywhere