Mobile Numeric Angular Keyboard

Asked

Viewed 379 times

0

Hello, I’m developing an angular form that will be used both on desktop and mobile.

However, I would like in mobile the numeric fields as CPF, Phone, Zip code, present only the numeric keyboard and not the complete keyboard!

How can I do that? Remembering that I cannot put the type: number in the input, because I use masks in these fields, and the type number input would not let me use these masks..

Thank you in advance...

1 answer

1


Just modify the type attribute in the input.

<input type="number"/>

or

<input type="tel"/>

EDIT:

<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.js"></script>
  </head>

  <body>
    <input id="CPF" type="tel" />

    <script>
      var cpf = $("#CPF");
      cpf.mask('000.000.000-00', {reverse: true});
    </script>
  </body>

</html>

...

  • In my question I inform that I can not do this way, because I use a mask Component

  • The type="tel" works my friend. I will edit the answer with an example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.