0

Hello i am trying to validate some form input where the format needs to be.

GBR (Exactly) followed by [1-9] for 1 digit then [0-9] for 2 digits and then nothing else.

I am using it inside some jquery.

            jQuery(function(){
            jQuery("#P3_P_CODE").validate({
                expression: "if (VAL.match(/^\w[GBR]{1,3}[1-9]{1,1}\d[0-9]{1,1}$/)) return true; else return false;",
                message: "Should be a valid Project format"
            });
        });

Meaning that

/^\w[GBR]{1,3}[1-9]{1,1}\d[0-9]{1,1}$/

is my regular expression.

The problem that i am having is that no matter what i type into the input box i am still presented with an error message meaning that my regular expression must be incorrect.

I have tried several different combinations in my REGEXP to no avail.

Any help would be appreciated

Paul Cunningham
  • 115
  • 2
  • 9
  • this page will probably help you http://stackoverflow.com/questions/280759/jquery-validate-how-to-add-a-rule-for-regular-expression-validation – wirey00 Mar 11 '13 at 18:15

1 Answers1

2
/^GBR[1-9]\d\d$/

[GBR] means one of those characters.

a better oliver
  • 26,330
  • 2
  • 58
  • 66