memberlogin
contactus
randomfacts

How to validate that a value is numeric

The isnumeric function is easy to use, simply place a value or variable in the isnumeric expression and if the result is false then it\'s not numeric and if it\'s true then it is numeric.

<%

         tmpval = 123

        if isNumeric(tmpval) then

               Response.write "The value:"&tmpval&" is numeric"

       else

              Response.write "The value:"&tmpval&" is not numeric" 

       end if

        tmpval2 = "abc"

       if isNumeric(tmpval2) then

               Response.write "The value: "&tmpval2&" is numeric"

      else

              Response.write "The value:"&tmpval2&" is not numeric"   

      end if

%>
The example above will result in the following being outputted to the screen.

The value: 123 is numeric

The value: abc is not numeric