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?
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 ConnectWise

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
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.

All Courses

From novice to tech pro — start learning today.