-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
  • 779
  • 2
  • 15
  • 38

2 Answers2

0
if(disName.substring(0,3) == 'com')
vinayr
  • 11,026
  • 3
  • 46
  • 42
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
  • 8,238
  • 1
  • 33
  • 52