Add if else condition to a TextInput

Hi, I want to add a textinput to my page for a phone number but set a condition to the textinput user should enter exactly 11 digits no more or less than 11 digits.
I have tried this code but it doesn’t work, I think I have a problem choosing the wrong event handler.

export function phoneinput_onFocus(event) {
    var re = new RegExp('\d{11}');
    let ph = $w('#phoneinput').value;
    if (ph.match(re)) {
      console.log("true");
    } else {
      console.log("false");
    }
}

Can you guys help me?

try this:

export function phoneinput_onInput(event){
   const value = event.target.value;
   if(value.length === 11){
      console log("true")
   } else {
       console.log("false")
   }
}