My string messege contain the string either this:
var strMessage = "Plcc-failed|Score-passed|bankruptcy-passed|Years in Business
i.e. it contains a " | " symbol in it or this
var strmsg="fail".
I need a javascript function to check whether it contains a "fail" msg or " | " symbol.
How to write a javascript function for it.
Thanks in advance
Loading
Abhay ShankerPosted Nov 26, 2013, 8:45 AM
var str="Plcc-failed|Score-passed|bankruptcy-passed|Years in Business";
var n=str.split("|");
var disp;
alert(pipeindex);
for(var i=0;i<4;i++)
{
if(i==0)
disp=n[i];
else
disp=disp+n[i];
alert(disp);
Ahmar HusainPosted Nov 26, 2013, 11:48 PM
if(strMessage.search('|')>=0)
{
alert("String contains |");
}
else if(strMessage=="fail)
{
alert("fail");
}
search method of javascript return the index of character searched in the string if the string doesnot contain the searched character it returns a negative integer in most cases it is -1.