aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Check if String Contains Specific Word in JavaScript

Sep 12, 2013

Here I will explain how to use
jQuery to check particular word in string in JavaScript or jQuery to check if string contains specific word in JavaScript.

In previous articles I explained jQuery add border to images in webpage, jQuery show loading image in pageload, jQuery hide div elements after 5 seconds, jQuery convert am / pm time to 24 hours time, jQuery print div content with css
and many articles relating to JQuery, JavaScript. Now I will explain how to check if string contains specific word in JavaScript.

To check particular word in string we need to write code like as shown below

<html xmlns="">
<title>jQuery Check Particular word in string in JavaScript</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(function() {
$('#btnCheck').click(function() {
var str = 'how are you';
var txt = $('#txtword').val();
if (str.indexOf(txt) > -1) {
alert('String Contains Word');
return true;
} else {
alert('String Does not contains word');
return false;
Check word in this String: <b>How are You</b><br />
Enter Text to Search: <input type="text" id="txtword" value="how" />
<input type="button" id="btnCheck" value="Check" />
Live Demo

Check word in this String: How are You

Enter Text to Search:

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

Dear sir,
What is the SMTP Server Name & Port Number for Yahoo.
please sir i requested to u ......plz plz tell me this one....)

I Used
SMTP Server Name
Port Number:

My program is showing send mail but actually mail is not send......):

ranadheerrannu said...

* Incoming Mail Server (POP3):
Use SSL, port: 995
* Outgoing Mail Server (SMTP):
Use SSL, port: 465, use authentication

i found it here:

Pwna|d said...

This doesn't really have anything to do with jQuery...

Anonymous said...

thank you

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.