I am trying to validate the length of a zip code to 5 digits. Below is my PHP validation function:
<?php
function checkZipCode( &$fields )
{
$zipcode = $fields[ZipCode];
$zipstring = (string)$zipcode;
$length=strlen($zipstring);
if ($length == 5){
return true;
}else{
return false;
}
}
?>
and my input field looks like
<input name="ZipCode" id="zipcode" class="text" type="text" eform="Your Zip Code:string:1:must be 5 numerals:#FUNCTION checkZipCode"/></label>
Of course, I called the "checkZipCode" snippet on the page as well. The problem that I’m having is that any input I give it returns as false, even if I input 5 digits. Am I showing my PHP greenness here? Am I not using the function validation properly?
Thank you for all of your help.