-1

Possible Duplicate:
Javascript StartsWith

I have a function in JavaScript which takes a string as parameter. Prototype:

function activateTab(pageId, tabCtrl, divId, otherdivId1, otherdivId2, disName);

I want to check if the last parameter, which is disName starts with "com". For example: "ComSomeName", or "ComSomeOtherName".

Community
  • 1
  • 1
Hanady
  • 773
  • 2
  • 13
  • 37

2 Answers2

0
if(disName.substring(0,3) == 'com')
vinayr
  • 9,293
  • 3
  • 41
  • 40
0

Try this

var n= disName.search("your string");

if it return 0 then start with your string if it return -1 not found

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_search first try to search in google then post question!

Jobin
  • 7,778
  • 1
  • 29
  • 50