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

1

1 Answer 1

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

[GBR] means one of those characters.

Sign up to request clarification or add additional context in comments.

5 Comments

I see what you mean :) i have added your changes but it is still not accepting a value of GBR101 for instance.
The regular expression works: example. What plugin are you using for validation?
According to the documentation there is no "expression" option.
Ahhh briliant, so obviously no matter what i entered mine would of returned false, my mistake i'll see if i can find a library that includes an expression option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.