Showing posts with label check for numbers. Show all posts
Showing posts with label check for numbers. Show all posts

Monday, May 11, 2009

check only for numbers in JavaScript

This code will show you how to check only for numbers in JavaScript.


<script type="text/javascript">

var input = '112334';
var vali_regex = /^[0-9]+$/;

if(input.match(vali_regex))
{
alert('This is a number');
}
else
{
alert('Not a number');
}
</script>