Find out if a text entry includes a specific text with jquery

advertisements

what is the best way of finding out if a text input includes a specific text with JQuery?

For example, how can I find out and return a Boolean result if $('#poo').val() includes airport?

EDIT

Here is the solution to my problem thanks to @Niklas;

var IsbtFortxtPropertyHotelNameOn = false;
$('#<%: txtPropertyHotelName.ClientID %>').keyup(function() { 

    if (/airport/i.test(this.value) && !IsbtFortxtPropertyHotelNameOn) {
        $('#<%: txtPropertyHotelName.ClientID %>').btOn();
        IsbtFortxtPropertyHotelNameOn = true;
    } else if(IsbtFortxtPropertyHotelNameOn && !/airport/i.test(this.value)) {
        $('#<%: txtPropertyHotelName.ClientID %>').btOff();
        IsbtFortxtPropertyHotelNameOn = false;
    }
});


If you want to have control over the case-sensitivity, you could use regex:

if (/airport/i.test(this.value)) alert('true');

It becomes especially useful if you need to check for multiple variables instead of just airport:

if (/(airport|station|docks)/i.test(this.value)) alert('true');

http://jsfiddle.net/niklasvh/tHLdD/