Linked Questions
184 questions linked to/from Validate decimal numbers in JavaScript - IsNumeric()
403
votes
6
answers
551k
views
Pure JavaScript: a function like jQuery's isNumeric() [duplicate]
Is there is any function like isNumeric in pure JavaScript?
I know jQuery has this function to check the integers.
128
votes
3
answers
190k
views
Check whether a value is a number in JavaScript or jQuery [duplicate]
Possible Duplicate:
Validate numbers in JavaScript - IsNumeric()
var miscCharge = $("#miscCharge").val();
I want to check misCharge is number or not. Is there any method or easy way in jQuery or ...
40
votes
10
answers
79k
views
Check that variable is a number [duplicate]
How can I check that a variable is a number, either an integer or a string digit?
In PHP I could do:
if (is_int($var)) {
echo '$var is integer';
}
Or:
if (is_numeric($var)) {
echo '$var is ...
45
votes
6
answers
231k
views
How to write isNumber() in JavaScript? [duplicate]
My guess would be:
function isNumber(val) {
return val === +val;
}
Is there a better way?
Previous Reference
Validate decimal numbers in JavaScript - IsNumeric()
3
votes
3
answers
8k
views
IsNumeric() similar function to js [duplicate]
I have a code that takes some numbers from a user.I want to ensure that the data given from the user are numbers and not strings.From my knowledge to vb6 I know i can use IsNumeric so I was wondering ...
8
votes
2
answers
3k
views
How can I allow only numbers, one comma, and two digits after the comma in my input field? [duplicate]
I have an input field, that only allows numbers and one point.
$('.number').keypress(function(event) {
var $this = $(this);
if ((event.which != 46 || $this.val().indexOf('.') != -1) &...
4
votes
2
answers
9k
views
Javascript: Validate a field: Not empty & only contains numbers [duplicate]
Possible Duplicate:
Validate numbers in JavaScript - IsNumeric()
Hi I am trying to validate a field using javascript to ensure that the field is not empty AND only contains numbers
I am using ...
5
votes
4
answers
628
views
What causes isNaN to malfunction? [duplicate]
I'm simply trying to evaluate if an input is a number, and figured isNaN would be the best way to go. However, this causes unreliable results. For instance, using the following method:
function ...
1
vote
3
answers
4k
views
What's the easiest way to check if a javascript variable is a number and greater than zero? [duplicate]
I coded this:
isNumberNotZero: function (num) {
// Return false if num is null, an empty string or zero
if (num === null || typeof num === "undefined" || (typeof num =...
4
votes
2
answers
3k
views
javascript function to avoid two decimal points (ex: 12.1.1 ) in html input text field [duplicate]
Can anyone help me out to found a solution to validate a text field to accept a valid decimal number. I tried something like
function fun_AllowOnlyAmountAndDot(txt) {
if (event.keyCode > 47 &...
2
votes
1
answer
3k
views
Detecting, whether user enter a string value or number in to a input field [duplicate]
I have an input field and one button. When the user clicks the button, first I check whether they entered a number or not. If it is a non-numeric string then nothing should happen. If it's a number ...
1
vote
5
answers
1k
views
Javascript function that is equivalent for PHP function [duplicate]
I have the follwing code in PHP:
if(is_numeric($first_name[0]) === true){
//Do something
}
How would I be able to do the same check using JavaScript? I also would like to get a PHP script to ...
0
votes
1
answer
1k
views
JavaScript test if number variable is a number [duplicate]
I’m loading a JSON file a reading the values into an array using a for loop
I’m concerned that sometimes the JSON file might become corrupted ie the values Im reading in might become ASCII letters ...
0
votes
3
answers
238
views
Regex to match a valid integer or decimal number (may be positive or negative) [duplicate]
I want my ExtJS textfield to allow only numbers and decimals (Both positve and negative) .I need a regex to allow an integer or decimal number which can be positive or negative .
Should match -
1) ...
0
votes
1
answer
102
views
What's the most concise way to check for an integer or float in JavaScript? [duplicate]
I want a concise expression to tell me if a given value is an integer or float. When provided the input value NaN or Infinity, I want the output value to be false, so this rules out simply checking ...