regex - Javascript Regular Expression Error Testing a Postcode -


I'm trying to use the regular postcode specified expression here: with javascript, but it does not seem to work I am using:

  var postcode = "^ (([gg] [ii] [rr] {0,} 0 [aa] {2}) | (( ([A-public relations-uwyzA-PR-UWYZ] [a-HK-ya-h-y] [0-9] [0-9]) | (([a-public relations-uwyzA-PR-UWYZ] [ 0-9] [a-hjkstuwA-HJKSTUW]) | ([a-pr-uwyzA-PR-UWYZ] [a-hk-ya-HK-Y] [0- 9] [abehmnprv-yABEHMNPRV-Y])) ) {0,} [0-9] [abd-hjlnp-UW-zABD-HJLNP-UW-Z] {2})) $ "; var aPCode = frm.PCode.value; If (((Postcode.test (aPCode))) {Enter + "Invalid Postcode. \ N"; }   

The error I am getting is if (! (Postcode.test (aPCode))) with line IE 7 (the browser in which I have JavaScript Errors are enabled) report with error "object does not support this property or method." This means that I can not use the .test method on the string, but that's where it is supposed to be used, right? I have not found a mistake with my code.

postcode is a string, is not a regular expression, it is forwarded in slash Wrap and wrapping quotes to make it a regular expression:

  var postcode = / ^ (([gg] [ii] [rr] {0}} 0 [aa] {2 }} | ((([One-person contact-uwyzA-PR-UWYZ] [one-h-ya-h-y] [0-9] [0-9]) | (([To make a public relations- UwyzA-PR-UWYZ] [0-9] [one-hjkstuwA-HJKSTUW]) | ([a-public relations-uwyzA-pr-UWYZ] [a-HK-ya-h-y] [0-9] [abehmnprv -yABEHMNPRV-Y]))) {0,} [0-9] [ABD-HJLNP-Yew-Zab D-Acjeelanpi-UW-Z] {2})) $ /;   

Various postcode = "^ (([gg] [ii] [rr] {0}} [[AA] {2}) | ((([A-PR-UVIS A-PR-UWAZ] [A-HK-ya -H-Y] [0-9] [0-9]) | (? ([A-public relations-uwyzA-PR-UWYZ] [0-9] [one-hjkstuwA-HJKSTUW]) | ([A -PR -UV-A-PR -YYYZ] [AHK-YA-H-Y-Y] [0-9] [ABMMPRV-Y])) {0,} [0- 9] [ABD-HJLNP-UW- ZABD-HJLNP-UW-Z] {2})) $ "; var postcode = new regx (postcode);

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -