I would like to validate a user zip code to match the area we work... Example: user type 77070 as zip code... I would like to check if this field belong to my work area which is 77070, 77373, 77379, 77380, etc...
Extra info: a Ajax function I got from the inet its calling the function in .PHP that request the user zip code.
I have try so many differents way to validate but define I am doing something wrong.
follow its what I have so far... the script its working but do not validate nothing.
*---> Validate function
<SCRIPT LANGUAGE="JavaScript">
function validateZIP(field) {
$fields = array('77070', '77373', '77380');
foreach ($fields as $field) {
if $_POST[$field] == "" {
echo "$field is empty"; }
}
}
// End -->
</script>
*---> Form requesting user zip code
<form action="guestip.php" method="post" name="GuestArea" id="GuestArea" onsubmit="MM_validateForm('ZipCode','','RisNum');return document.MM_returnValue">
<table width="496" height="157" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="369" height="157" background="images/HiGuest.png"><table width="100%" height="144" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="262" height="20">*</td>
<td width="140" valign="bottom"><strong><font color="red"><? echo getenv('REMOTE_ADDR'); ?></font></strong></td>
<td width="94" valign="bottom">*</td>
</tr>
<tr>
<td height="20">*</td>
<td valign="bottom">*</td>
<td valign="bottom">*</td>
</tr>
<tr>
<td height="20">*</td>
<td valign="bottom">*</td>
<td valign="bottom">*</td>
</tr>
<tr>
<td height="50">*</td>
<td valign="bottom"><input name="ZipCode" type="text" id="ZipCode" size="5" maxlength="5"/></td>
<td valign="bottom"><input type="submit" name="Submit" value="Thank You" onSubmit ="return validateZIP(this.ZipCode.value)" /></td>
</tr>
<tr>
<td height="4">*</td>
<td valign="bottom">*</td>
<td valign="bottom">*</td>
</tr>
<tr>
<td height="4">*</td>
<td valign="bottom">*</td>
<td valign="bottom">*</td>
</tr>
</table></td>
</tr>
</table>
</form>
*********************************
I will be extremely thankful for any help... I am open for any new ways to make this work.
tks a lot Y!All
PS: you can see this script working in my web www.creativelawnservice.com but not validating nothing.
Extra info: a Ajax function I got from the inet its calling the function in .PHP that request the user zip code.
I have try so many differents way to validate but define I am doing something wrong.
follow its what I have so far... the script its working but do not validate nothing.
*---> Validate function
<SCRIPT LANGUAGE="JavaScript">
function validateZIP(field) {
$fields = array('77070', '77373', '77380');
foreach ($fields as $field) {
if $_POST[$field] == "" {
echo "$field is empty"; }
}
}
// End -->
</script>
*---> Form requesting user zip code
<form action="guestip.php" method="post" name="GuestArea" id="GuestArea" onsubmit="MM_validateForm('ZipCode','','RisNum');return document.MM_returnValue">
<table width="496" height="157" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="369" height="157" background="images/HiGuest.png"><table width="100%" height="144" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="262" height="20">*</td>
<td width="140" valign="bottom"><strong><font color="red"><? echo getenv('REMOTE_ADDR'); ?></font></strong></td>
<td width="94" valign="bottom">*</td>
</tr>
<tr>
<td height="20">*</td>
<td valign="bottom">*</td>
<td valign="bottom">*</td>
</tr>
<tr>
<td height="20">*</td>
<td valign="bottom">*</td>
<td valign="bottom">*</td>
</tr>
<tr>
<td height="50">*</td>
<td valign="bottom"><input name="ZipCode" type="text" id="ZipCode" size="5" maxlength="5"/></td>
<td valign="bottom"><input type="submit" name="Submit" value="Thank You" onSubmit ="return validateZIP(this.ZipCode.value)" /></td>
</tr>
<tr>
<td height="4">*</td>
<td valign="bottom">*</td>
<td valign="bottom">*</td>
</tr>
<tr>
<td height="4">*</td>
<td valign="bottom">*</td>
<td valign="bottom">*</td>
</tr>
</table></td>
</tr>
</table>
</form>
*********************************
I will be extremely thankful for any help... I am open for any new ways to make this work.
tks a lot Y!All
PS: you can see this script working in my web www.creativelawnservice.com but not validating nothing.