javascript - I cant get this script to work in IE, what am I doing wrong -
i wanting use script , finding wont work in internet explorer. t work in other tested browsers. thanks
<form name = "myform"> <b>to find if service area,<br> please enter postcode</b><br> <input type = "text" name = "zip" size = "4" maxlength = "4" onchange = "checkzip()"> </form> <script type = "text/javascript"> function checkzip() { var z = document.myform.zip; var zv = z.value; if (!/^\d{4}$/.test(zv)) { alert ("please enter valid postcode"); document.myform.zip.value = ""; myfield = z; // note myfield must global variable settimeout('myfield.focus(); myfield.select();' , 10); // fix bug in firefox return false; } var codes = [4000,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,4030,4051,4059,4064, 4065,4066,4075,4101,4102,4103,4104,4105,4106,4107,4108,4109,4110,4111,4112, 4113,4114,4115,4116,4117,4119,4120,4121,4122,4123,4127,4128,4151,4152,4153, 4154,4155,4156,4157,4158,4159,4160,4161,4163,4164,4169,4170,4171,4172,4173, 4174,4178,4179]; // add many zip codes like, separated commas (no comma @ end) var found = false; (var i=0; i<codes.length; i++) { if (zv == codes[i]) { found = true; break; } } if (!found) { alert ("the post code " + zv + " not in our database, please call 1300 736 979 check , see if can you."); document.myform.zip.value = ""; return false; } else { alert ("yes, post code covered our business"); } } </script>
Comments
Post a Comment