Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What pattern to use in paper-input to decimal number?

I would like a pattern for decimal number in paper-input for following outpus:

 111.111,11 >>> true 
 111,11 >>> true 
 0,11 >>> true

I am using the following pattern:

"^([0-9]{1,3}\.)?[0-9]{1,3}\,[0-9]{2}$?"

in the code:

<paper-input type="number" pattern="^([0-9]{1,3}\.)?[0-9]{1,3}\,[0-9]{2}$?" auto-validate error-message="Não é um número válido!" label="Faturamento Anual" value="{{parametro.faturamentoAnual}}"><div prefix>R$</div></paper-input>

But when I type 0,11 and return false with the error-message.

Is there a different pattern to decimal number in paper-input that works?

like image 543
Muka Avatar asked Nov 19 '25 00:11

Muka


1 Answers

The ? at the end of your regex doesn't make sense to me. I tried it without the ? and it worked fine. I also had to remove type=number to be able to enter anything at all. A plain <input type="number"> doesn't allow , or . as well.

like image 186
Günter Zöchbauer Avatar answered Nov 22 '25 05:11

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!