hello i need to verify numeric input in dollar amount, My problem is i made a regex for it and someone told me im better off using number format, But what ive made does not restrict it to proper format, Here is what ive had both times.
$number = $_POST['amount'];
$amount = number_format($number, 2, '.', '');
if(isset($amount) && (!empty($amount)) && strlen($amount) < 4 || strlen($amount) > 9)
{
$errors[] = "The payment amount entered must be in proper format. (i.e 100.00, 40.00)";
}else{
$amt = trim($_POST['amount']);
and
<?php
if(!eregi('^[1-9]{2,3},|\.[0-9]{2,3}\.[0-9]{2}', stripslashes(trim($_POST['amount']) ) ) )
{
$problem = TRUE;
}
if(!$problem)
{
echo 'Thank you.';
}else{
echo 'Please go back and enter a proper ammount
}
?>
Can anyone suggest a better way (or at least one that might work 🙂 )