• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 67
  • Last Modified:

checking input of textbox

This is a follow up to this ticket.


This is just for learning purposes, learning to work with regex.

So in the example in that ticket, how would I revise it to the following.
Either using regex or jquery or JavaScript.

Add a button called Button1.

If I type the less than sign proceded by the forwad slash sign like this </ then hide the button.
If I type the greater than sign preceded by the forwad slash sign like this /> then hide the button.
  • 3
1 Solution
Julian HansenCommented:
Is the button disabled if there is any /> or </ in the text
Is the button disabled only at the point that you type the > in '/>'' or the '/' in '/>'
Julian HansenCommented:
Here is a sample that works on the contains approach
<textarea class="form-control" id="tester"></textarea>
<button class="btn btn-primary" id="thebutton">Click me</button>

Open in new window

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

Open in new window

Working sample here
maqskywalkerAuthor Commented:
Thanks! Great example!
Julian HansenCommented:
You are welcome.
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now