9951 explained code solutions for 126 technologies


javascriptCheck if a string is a valid number


var str = '25.99';
var is_numeric = (typeof str == 'string') && !isNaN(parseFloat(str));ctrl + c
var str

declare test string with number

typeof str == 'string'

ensure str is of string type

isNaN(parseFloat(str))

ensure str contains valid number