Monaca Onsen UI Discord Chat Github Repo

how to handle maxlength of numberic input

  • i use ons-input in my form and need to have number type attribute for some of them. but unfortunately it couldn’t handle maxlength. this is my code :

    <ons-input class="txt" maxlength="5" type="number" placeholder="Cell Number" input-id="txtRecover" />

  • Onsen UI

    @meisam3322 Hello!

    Copy-pasting from the other place where you also asked this:

    @meisam3322 That’s how HTML5 works. But Google and SOF have a bunch of solutions for you.

    Basically, you can use min and max attributes to specify a range and oninput event if you want to check the length.

    However, if what you are trying to do is to write a telephone number input, maybe you can use type="tel" and keep using max-length.