Javascript function that is equivalent for PHP function -
this question has answer here:
i have follwing code in php:
if(is_numeric($first_name[0]) === true){ //do }
how able same check using javascript? php script check if there number in $first_name @ all, don't want user add number in first or last names please?
if (/-?\d+(?:\.\d*)?(?:[ee][+\-]?\d+)?/.test(yourinput)) { // }
of course, work on strings. different method, see duplicate question:
function isnumber(n) { return !isnan(parsefloat(n)) && isfinite(n); }
to check if input contains number (0-9) @ all, regex works again:
if (/[0-9]+/.test(yourinput)) { // }
Comments
Post a Comment