Javascript runtime error:
I urge the following JS to check the UK zip code:
<script type="text/javascript"> function jsre(theField) { var chk_postalcode = "^[A-Z0-9 ]*[AZ][A-Z0-9 ]*\d[A-Z0-9 ]*$|^[A-Z0-9 ]*\d[A-Z0-9 ]*[AZ][A-Z0-9 ]*$"; var txtpostalcode = document.getElementById("txtPostCode"); if (!chk_postalcode.test(txtpostalcode.value)) { alert("Valid"); } else { alert("Invalid"); } } </script> <asp:TextBox ID="txtPostCode" runat="server" onchange="jsre(this);"></asp:TextBox> I get a runtime error like:
Error: Object doesn't support property or method 'test' I asked for help http://www.9lessons.info/2009/03/perfect-javascript-form-validation.html in the frame of my code.
Can someone help me how can I make the code work?