I have searched for a script like this one but I can’t find it. I’m trying to make a price validation script that will allow strings like…
[LIST]
[]42
[]42.5
[*]42.50
[/LIST]
But will disallow and prompt me for strings like…
[LIST]
[]abcd
[]ac42
[]42ab
[]4512
[]85&88)
[]42.50.30.20
[]42,50
[/LIST]
The script will only allow numbers and, if entered, at least one period and thats it. Can someone please help me or point me to the right direction.
Here is a script I have to make sure its ONLY numbers:
// ----- if the field should contain ONLY NUMBERS -----
if(eregi('number',$fieldnames[$i])&&$column!='')
{
// get fieldname in CAPS
$numberfield = str_replace('number', '', $fieldnames[$i]);
$numberfield = strtoupper($numberfield);
// strip everything that its not a number
$column = preg_replace('|[^0-9]|', '', $column);
if(!eregi('[0-9]', $column))
{
$errors .= '<li>Please enter digits as '.$numberfield.'.</li>';
}
}