working with regular expressions and jquery

I have this example fiddle:

In this example I'm using this regex pattern:


With this pattern only when you type </ together or /> together does validation pass and the button becomes enabled.

When you run it, it looks like this. The button is disabled.
So if you type the symbols separately that doesn’t pass.


If I type the </ symbols together regardless whether there is text before or after it, validation passes.
If I type the /> symbols together regardless whether there is text before or after it, validation passes.


How do I revised my regex example to do the opposite?
I want to add Not to this regex pattern /<\/|\/>/

So in my example the validation should pass for everything except </ or this />

The tooltip should only popup if I type </ or this />
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

David S.Commented:
To reverse it, simply add the not operator ("!") immediately before the expression (the JS one, not necessarily the RegEx one, but in this case it's the same, since you're using one of the methods of RegEx objects).

            jQuery.validator.addMethod("HTMLCheck1", function (value, element) {
                return this.optional(element) || !/<\/|\/>/.test(value);
            }, "Only LTForwardSlash or ForwardSlashGT is allowed");

Open in new window

To look for strings that do NOT have </ or />, use this regex:

Or what David S. said.

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

pls try

Open in new window

maqskywalkerAuthor Commented:
thanks. great examples.
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
Regular Expressions

From novice to tech pro — start learning today.