Technology
 

Validating Numbers and Integers

From Unofficial Konfabulator Wiki

The following functions will check whether a string is a number or an integer respectively.


function isNumeric(s) {
	return parseFloat(s).toString() != 'NaN';
}
function isInteger(s) {
	return parseFloat(s).toString() != 'NaN' && parseFloat(s) == parseInt(s);
}
Rate this article: