V
V
Vadim2015-07-18 16:55:39
Angular
Vadim, 2015-07-18 16:55:39

How to check part of a regular expression?

It is necessary to write a directive that would block input on inputs if the entered character contradicts the mask. Everything would be fine, but this kind of functionality is needed. Write a regular expression to the directive and use it to check each time whether the entered character matches this expression. There is of course ngPattern, but it just says whether or not it matches the given regular expression. And it is necessary to block input if the regular expression is broken. I don't know how to check part of reg. expressions, so hastily made multiple expressions for each character ( https://github.com/Monstro13/multi-patterns-mask ). But this is also not an option. because if the expression needs 2 or more static sequences, then this will not help.
For example check the same year. Allow dates 1900 - 2100. If you hang on each character reg. expression then will pass wrong dates: 2999 for example.
I would like to know if this problem can be solved? I repeat that it is necessary to dynamically track the compliance of reg. expression and optionally block input.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-07-18
Protko @Fesor

Why are you binding keyPress? There is ngModel, not valid - reset the value to the last valid one (an invalid value is not written to $modelValue).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question