I write my plugin "mask" on javascript + jquery. I coped with the option "user sets a mask for example 000-00-00" - it means that instead of 0 in input there can be only a digit in this place. Also coped with the moment "the user sets a regular expression" and analyzes the value of input for the search for invalid characters. Now I’ve wondered: is it possible to convert a regular expression in some way, for example \d{1,3} into a value input value = "___" (three underscores that are replaced when typing from a keyboard to a valid one for a given position in the input symbol)? This example is of course simple, it can be calculated, but for example a regular expression that allows you to enter a valid e-mail is already complicated. Are there any such ways or am I bothering with unrealizable?
- You want strange. Regulars are complex and not all of them can be expressed by a mask. Even in your example, you have already invented some kind of hack (why three underscores, not one?) - Alexey Ten
- because in the sense of the regular expression "numbers from one to three" - this is why three _ - Ilya Bazhinov
- In my opinion, you complicate. It is more convenient to use two parameters in the plugin - the mask and the regular expression itself. - Stepan Kasyanenko
- @StepanKasyanenko do not quite understand what you mean by two parameters in this context. A regular season is a regular season, and a mask ... how does it look relative to my regular season? but you are right, I turned it and this and that way - too much then everything goes unwieldy - Ilya Bazhinov
|