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
How to check in javascript that string contains a substring or not
Posted by
Rajesh Rolen
at
Friday, March 12, 2010
Labels: java script
0 comments:
Post a Comment