How I can validate a age feild in php with preg_match to only accept number between [18 – 60].
Here is the code I write to accept 2 digit only, but I want to specify a reange of number.
if(preg_match("/^\d{2}$/", $_POST["age"]) === 0)
$errage = '<p class="errText">Age must between 18 -60 digits </p>';
You don’t need regular expression at all:
And just for the information – this is how regex would look like: