PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

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


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 
"57a";
if(
is_numeric($formvalue)) { echo "Is a number"; } else { echo "Not a number"; }
?>


This prints 'Not a number' in this instance.



ASK A QUESTION

More forms PHP Questions

How do I make a website field mandatory?

1.want to know simple logic and procedure of FORM VALIDATION? 2.How to check Login and password in PHP?

I have a form that I need to do two things: send all the input values to a confirmation/pay page, and send to me via email. Payment is based on what the customer picks (naturally). The way I have it set up is the form action goes to the confirmat

Dear Friends, I need to enable the user to add a drop down menu and a text field by only clicking on button (in case the user wants more) I have the following codes how do I make it better: Enter User : Truck Mixer

How can I check that a data value is alphanumeric?



Custom Search