rogerzebra
Technical User
hi,
I'm using formvalidation classes as validation, an execellent script I found somewere. Now I'm trying to add a date class and a class for street adresses, which I obviously can't get to work and could need someone to help out.
I have a form containing datefields( a javascript calender)on it and even that the fields has date information on them when executing the form, I get an error which indicate that both datefields are empty.
So now I'm not sure if my added regex classes for dates and streetaddress is correct? Once again if anyone could take time to look at them would be much appreciated.
This is the class script
Thanks in advance
/rz
I'm using formvalidation classes as validation, an execellent script I found somewere. Now I'm trying to add a date class and a class for street adresses, which I obviously can't get to work and could need someone to help out.
I have a form containing datefields( a javascript calender)on it and even that the fields has date information on them when executing the form, I get an error which indicate that both datefields are empty.
So now I'm not sure if my added regex classes for dates and streetaddress is correct? Once again if anyone could take time to look at them would be much appreciated.
This is the class script
Code:
class FormValidator
{
var $_errorList;
function _getValue($field)
{
global ${$field};
return ${$field};
}
function FormValidator()
{
$this->resetErrorList();
}
//This is the classes I added
function isDatefield($field, $msg)
{
$value = $this->_getValue($field);
$pattern = "/^([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})$/";
if(preg_match($pattern, $value))
{
return true;
}
else
{
$this->_errorList[] = array("field" => $field, "value" => $value, "msg" => $msg);
return false;
}
}
function isStreetAddress($field, $msg)
{
$value = $this->_getValue($field);
$pattern = "/^[0-9]+[a-zA-Z]+[a-zA-Z,]+[a-zA-Z]+[\d{5}]$/";
if(preg_match($pattern, $value))
{
return true;
}
else
{
$this->_errorList[] = array("field" => $field, "value" => $value, "msg" => $msg);
return false;
}
}
/rz