working with regular expressions and jquery

This is a followup to the example in this ticket.

I created the example in this fiddle.

In this fiddle example this is what it looks like when you run it.
Notice the button is disabled. The textbox gets validated to see if user typed a less than sign < or greater than sign >

on run

I'm using a regular expression to check for a less than sign < or greater than sign > in the textbox.

If user types this < then they get this message:

If user types this > then they get this message:

If they type in regular text, validation passes and the button becomes enabled.


In this example fiddle I'm using a regular expression , I'm learning to work with regular expresssions.

How do I revise my fiddle example to check for what the example in this ticket does:

That ticket example test this:

  $('#tester').keyup(function() {
    var disabled = $(this).val().indexOf('/>') > 0 || $(this).val().indexOf('</') > 0;
    $('#thebutton').prop({disabled: disabled});

What is the equivalient of this:  var disabled = $(this).val().indexOf('/>') > 0 || $(this).val().indexOf('</') > 0;

Using a regular expression?
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.

Miguel OzSoftware EngineerCommented:
Regular expression to detect <  and >: [<>])
  var value = $(this).val();
  var regextest = new RegExp('[<>]');
  var disabled = regextest.test(value);

Open in new window


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
Regular Expressions

From novice to tech pro — start learning today.