working with regular expressions and jquery

I have this example fiddle:
https://jsfiddle.net/h6vkt3jg/2/

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.
 
Run1.PNG
So if you type the symbols separately that doesn’t pass.

Run2ErrorMessage.PNG


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


Run3Pass2.PNG

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 />
LVL 1
maqskywalkerAsked:
Who is Participating?

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

x
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

0
gr8gonzoConsultantCommented:
To look for strings that do NOT have </ or />, use this regex:
/^((?!<\/|\/>).)*$/.test(value)

Or what David S. said.
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
Rgonzo1971Commented:
Hi,

pls try
^(<\/.*\/>|(?!.*<\.*)(?!.*\/>.*).*)$

Open in new window

REgards
0
maqskywalkerAuthor Commented:
thanks. great examples.
0
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.