In PHP, it\'s pretty easy:
is_numeric(23);//true is_numeric(\"23\");//true is_numeric(23.5);//true is_numeric(true);//false
But how do I do
This checks for numerical values, including negative and floating point numbers.
function is_numeric(val){ return val && /^-?\d+(\.\d+)?$/.test(val + ''); }
@Vordreller: I corrected the Regex. It should work properly now.