Numeric Validation in PHP | Validations in Forms

Numeric Validation in PHP

0 3029

Numeric validation means input field of mobile should be numeric and maximum digit of numbers should be 10. If field is blank, then form will not be submit without enter the value of 10 numeric digit. For more details use below code and example.

You can modify below code as your requirement.


echo "Please enter a value.";
else if(!is_numeric($phone))
echo "Value entered is not numeric.";
else if(strlen($phone) !=10)
echo "Please enter 10 digits number..";
echo "<table align='center'>
<td>Mobile Number is:<input type='text' value='".$phone."' readonly/></td>

<!DOCTYPE html>

<meta charset="utf-8">
<title> Numeric Validation in PHP </title>


<form action="" method="post">
<table align="center" >
<td> <input type="phone" name="phone" placeholder="Mobile Number"> </td>
<td> <input type="submit" name="submit" value="Click Here"> </td>



Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments