Checking a value is number or not a number in Java Script

isNaN(Number)

Number->Required.

function returns ‘true’ if a number is not a numeric otherwise it will returns false.

example:

<script type=”text/javascript”>

document.write(isNaN(67)+ “<br />”);
document.write(isNaN(-4.34)+ “<br />”);
document.write(isNaN(”Tryangled”)+ “<br />”);
document.write(isNaN(”2007/12/23″)+ “<br />”);
</script>

The above script will return like this.
false
false
true
true

Posted by Kalaivani S

Leave a Reply

You must be logged in to post a comment.