Page 1 of 1
same multiple characters - xxxxxxxx
Posted: Mon Sep 12, 2005 12:39 am
by cribs
having an input form on the web, I keep receiving forms with values of xxxxxxxx, zzzzzzzzzzz etc. I need a way to validate the form and return a error message. Does anyone have any ideas, I know I can not be the only one.
Posted: Mon Sep 12, 2005 12:44 am
by feyd
create a definition of "valid" for each field, then either implement each (as needed) using regular expressions (regex) or simple string analysis.
here is the code I have to validate name_First form value
Posted: Mon Sep 12, 2005 4:56 pm
by cribs
<?php
switch($key)
{
case 'Date' :
$form_values[$key] = Date("m/d/Y");
break;
case 'name_First' :
$value = ereg_replace (' +', '', $value); // removing spaces in variable
if (empty($value))
{
$message .= 'You did not enter your first name.<br>';
}
else if(preg_match("/[0-9_=*&^%$#@!<>\[\]{}()]/",$value))
{
$message .= ' You entered an incorrect value for your first name.<br>';
}
$form_values[$key] = $value;
break;
}
?>