Allow only Numeric string in PHP

0
104
PHP

This tutorial explains how to restrict user to provide only Numeric input in Input Text in PHP

function is_numeric_text_input($data) {
if (!preg_match("/^[0-9]*$/",$data)) 
   return true;
else
    return false;
}

Here we use regular expression to validate the input. you can use this function anywhere in your project.

LEAVE A REPLY

Please enter your comment!
Please enter your name here