How to check whether a string is numeric in JavaScript

1 Answer

0 votes
function isNumeric(s) {
  return !isNaN(parseFloat(s)) && isFinite(s);
}

var s = "javascript01223c++3php500--9_8";


if (isNumeric(s))
    document.write("yes"); 
else
    document.write("no"); 
 
 
  
/*
run:
   
no
      
*/

 



answered Aug 2, 2019 by avibootz
...