I'm building a component to serve as an input for taking phone numbers which [you can see here.](https://plnkr.co/edit/2gHQwrqagGnbljo3bZmM?p=preview)

I'm using 3 text inputs to take each portion of the phone number and would like to use a function that controls which gets selected based on an if condition. So for example lets say the user clicks on what's technically the 3rd input to go about entering their number. I want it to automatically set the focus to the first input so they can start in the right place.

Here's my code so far.

template

```
<fieldset>
  <p class="input-container">
    (
    <input id="first" class="phnA" type="text"
      maxlength="3"
      pattern="^[0-9]{3}"
      placeholder ="123"
      [(ngModel)]="NumA"
      onselect="selection()"
    >
    )
    <input id="second" class="phnA" type="text"
      maxlength="3"
      pattern="^[0-9]{3}"
      placeholder ="456"
      [(ngModel)]="NumB"
      onselect="selection()"
    >
    -
    <input id="third" class="phnB" type="text"
      maxlength="4"
      pattern="^[0-9]{3}"
      placeholder ="7890"
      [(ngModel)]="NumC"
      onselect="selection()"
    >
  </p>
</fieldset>

```

function in component class

```
selection(){
    let a = document.getElementById('first');
    let b = document.getElementById('second');
    let c = document.getElementById('third');

    if( this.NumA.length > 3 ){
      document.getElementById("first").focus();
    }

    /*if(this.NumA.length < 3){
      a.focus();
    }else if(this.NumA.length = 3 && this.NumB.length < 3){
      b.focus();
    }else if(this.NumA.length = 3 && this.NumB.length = 3){
      c.focus();
    }*/
  }

```

My first attempt is the chunk that's commented out. I tried applying it directly to see if maybe I was losing something through making it a variable and it still doesn't force the cursor into the first input. The regexp I'm using to force numbers isn't working either. the `NumA, NumB, NumC` variables are all set to be `string` because `maxlength` for some reason doesn't work on `type="number` inputs which is a different issue, jsut mentioning for the sake of explaining why they're not of `number` type. What am I doing wrong here?