jQuery Validation Plugin regex formatting

i'm using the jQuery Validation Plugin.

I'm using asp.net web forms.

I have a html textbox that i'm validating.

The text box has masking applied to it. So the format is 123-45-6789

I created a custom validation method that looks like this.
            // custom validation method
            jQuery.validator.addMethod("SSNFormatting", function (value, element) {
                return this.optional(element) || /^\d{3}-\d{2}-\d{4}$/.test(value);
            }, "Please enter a 9-digit Social Security Number.");

Open in new window


So if a user doesn't type all nine digits they get that message.
So for example if they type   123-44-  
Then the validation message displays.

Is there a way to make another similar custom validation method that does the following?

If a user types all zeros like this:    000-00-0000
Then the validation should show this message.  "All zeros are not allowed"
But this message only shows if all zeros are typed.   Typing something like this is OK.  010-12-9202
The message should display only when all nine digits are zero.
LVL 1
maqskywalkerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
try:
            // custom validation method
            jQuery.validator.addMethod("SSNFormatting", function (value, element) {
                return this.optional(element) || (value!="000-00-0000" && /^\d{3}-\d{2}-\d{4}$/.test(value) );
            }, function(params,element){
                   var val = $(element).val().trim();
return val='000-00-0000' ? "All zeros are not allowed" : "Please enter a 9-digit Social Security Number.";
           });

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.