0

Hi,
I am using

ereg

for validations of field and I want to allow some fields that are optional but ereg does not allow me to validate space or empty field.My code for validation is

while(list($var,$val)=each($_POST)){
            
		
			if(!ereg($var,$admin_data)){

				if(ereg($reki[$var],$val)) {$class="good";}//this condition is checking the values of all the fields but I want some fields to be allowed

				else {$class="bad";$nbad++;}
					

				 $_SESSION["class"]["$var"]=$class;

				 $_SESSION["basic"]["$var"]=$val;

			}

		}

I have used this pattern but it is not working

$reki["business"]="{ }";
$reki["business"]=" ";

But no success.Can anyone help me.
Thanks in advance

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by saadi06
0
$reki["business"]=" *";

Would mean zero or more spaces, is that what you want ?

Sidenote: ereg has been deprecated, I suggest you switch to the preg_XXX functions instead.

0

Thanks a lot I have solved the problem and thanks for the information that ereg is deprecated

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.