top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How can I check a value entered in a field on my form is a number?

0 votes
66 views
How can I check a value entered in a field on my form is a number?
posted Jul 10, 2014 by Karamjeet Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

There are several ways that you can check that this is the case. One of the simplest ways is to use a dedicated function, is_numeric - just pass it the value and it'll return true or false depending on whether it is a number or not.
Here's an example:

<?php $formvalue = "3a"; if(is_numeric($formvalue)) { echo "Is a number"; } else { echo "Not a number"; } ?>
This prints 'Not a number' in this instance

answer Jul 11, 2014 by Rahul Mahajan
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...