hi I have this registation page that i'm having problems with.. It only understands us zip codes and not anyother like the u.k here is the code anyone could help so the php code understands all zip & post codes.. Thanks in advance.. Line 14: var zipcode = "document."+form_name+".txtZIP.value"; Line 80: if(eval(zipcode)!='' && validateZIP(eval(zipcode))) Line 80: if(eval(zipcode)!='' && validateZIP(eval(zipcode))) Line 82: alert("Enter valid zip code"); Line 168: //alert("Please enter your 5 digit or 5 digit+4 zip code."); Line 175: //alert("Invalid characters in your zip code. Please try again."); Line 179: //alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'. Please try again."); Line 15: var zipcode = "document."+form_name+".txtZIP.value"; Line 71: var zip_country = document.getElementById("billCountrySelect").value; Line 73: if(zip_country == "US" || zip_country == "UM") Line 73: if(zip_country == "US" || zip_country == "UM") Line 75: if(eval(zipcode)!='' && validateZIP(eval(zipcode))) Line 75: if(eval(zipcode)!='' && validateZIP(eval(zipcode))) Line 77: alert("Enter valid zip code"); Line 137: //alert("Please enter your 5 digit or 5 digit+4 zip code."); Line 144: //alert("Invalid characters in your zip code. Please try again."); Line 148: //alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'. Please try again."); PHP: Thanks for looking
Hi Thanks for the reply here are the js code return stringValue; } function validateZIP(field) { var valid = "0123456789-"; var hyphencount = 0; if (field.length!=5 && field.length!=10) { //alert("Please enter your 5 digit or 5 digit+4 zip code."); return true; } for (var i=0; i < field.length; i++) { temp = "" + field.substring(i, i+1); if (temp == "-") hyphencount++; if (valid.indexOf(temp) == "-1") { //alert("Invalid characters in your zip code. Please try again."); return true; } if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) { //alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'. Please try again."); return true; } another one } var zip_country = document.getElementById("billCountrySelect").value; if(zip_country == "US" || zip_country == "UM") { if(eval(zipcode)!='' && validateZIP(eval(zipcode))) { alert("Enter valid zip code"); return false; The html from the register.php <td align="right">State<span class="required">*</span></td> <td align="left"> </td> <td align="left"> <select id='billStateSelect' class='textarea2' name='bill_state'> </select> <SCRIPT type="text/javascript">initCountry(); </SCRIPT> </td> </tr> <tr><td align="right" >ZIP <span class="required">*</span></td> <td > </td><td align="left"><input type="text" value="<?php echo htmlentities($txtZIP);?>" class="textarea" name="txtZIP" maxlength="20"></td></tr> <tr> Thanks for your help
Looks like you need some javascript to accept input of uk postcodes. Get someone to rewrite / modify the function validateZIP(field) to allow 4chars + space + 3 chars which is the UK postcode format. Also you would need to add 'gb' or 'uk' as a country.