0

I need pattern for input (type="text"! not number) when is available numbers from 1 to 72 and available 0.5 (1.5, 2, 2.5, 65.5 ect.)

I tried by

ng-pattern="'^(?:[1-9](\.[05]*)?)|(?:[1-6][0-9](\.[05]*)?)|(?:7[01](\.[05]*)?)|72$'"

But not work correctly for example "1111a" ect.

Can you help me? http://regexr.com/3dkks

Albatros
  • 51
  • 1
  • 4
  • 1
    Why `input type="text"`? – Hopeful Llama Jun 15 '16 at 09:09
  • a [custom validator](https://docs.angularjs.org/guide/forms#custom-validation) is probably a better option – Rhumborl Jun 15 '16 at 09:10
  • Hopeful Llama because I sync value by this plugin http://ionden.com/a/plugins/ion.rangeSlider/demo.html and model is not number, but string. I added the same model in this input and in rangeSlider input – Albatros Jun 15 '16 at 09:21

1 Answers1

1

Try this: ^((?:[1-9](\.[05])?)|(?:[1-6][0-9](\.[05])?)|(?:7[01](\.[05])?)|72)$

i added the global quotes and remove * after [05]

here is plnkr

E. Abrakov
  • 463
  • 2
  • 6