Number only string detection
Posted: Mon Jul 17, 2006 8:26 am
Hi, I need to be able to detect if someone as not typed in numbers in a input field when its been submitted, can this be done?
I guess you'd something like
but i can't get this to work any ideas??
thanks
Mjay
I guess you'd something like
Code: Select all
<?php
// this would be $_POST[] etc not $date =
$date = "1";
if (ereg ("([0-9]{1,2})", $date, $regs)) {
echo "$regs[1]";
} else {
echo "Invalid date format: $date";
}
?>thanks
Mjay