# PHP - price validation script

**URL:** <https://forum.kirupa.com/t/php-price-validation-script/240938>\
**Category:** programming\
**Created:** [October 8, 2007, 3:02pm UTC](https://forum.kirupa.com/t/php-price-validation-script/240938 "2007-10-08T15:02:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [October 8, 2007, 3:02pm UTC](https://forum.kirupa.com/t/php-price-validation-script/240938/1 "2007-10-08T15:02:43Z")

</div>

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  
[_]45_12  
[_]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:

```php

			// ----- 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>';
				}
			}

```
