I would like to do something like this:
if (idCity == 'AB*') {
   //  do something
}
In other words. I want to check that idCity starts with the string "AB". How can I do this in Javascript?
I would like to do something like this:
if (idCity == 'AB*') {
   //  do something
}
In other words. I want to check that idCity starts with the string "AB". How can I do this in Javascript?
 
    
    if(idCity.substr(0,2)=='AB'){
}
If 'AB' is not constant string, you may use
if(idCity.substr(0,start.length)==start){
}
 
    
    if(idCity.indexOf('AB') == 0)
{
  alert('the string starts with AB');
}
 
    
    idCity = 'AB767 something';
function startWith(searchString){
    if (idCity.indexOf(searchString) == 0){
         return true;
    }
    return false;
}
