Monday, May 16, 2011

JavaScript isNumeric Function

This tutorial demonstrate a function that will tell whether given input is integer or not, let just move straight to the code

<script language="javascript" type="text/javascript">

function isNumeric(CHECK_CHAR){
 return !isNaN(CHECK_CHAR);
}

</script>
a sample example will be something like this...
<script language="javascript" type="text/javascript">

alert(isNumeric("1130"));
//true
alert(isNumeric("-17"));
//true
alert(isNumeric("460G"));
//false
</script>

No comments:

Post a Comment