Friday, March 12, 2010

How to check in javascript that string contains a substring or not

many of times we need to find out that a particular string contains a particular (charactor or string ) or not.
so below example will help you.
var varA = "hello how r u";
if(varA.indexOf("How") != -1)
{
alert('it contains How');
}
else
{
alert('it not contains how');
}

Article by: Rajesh Rolen

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates