- š¦š¹Austria maxilein
I tried the patched changes, but could not get it to work.
What did you put into the regex under admin/config/content/mask ?
Thank you. - š¦š¹Austria maxilein
Could you please provide a patch that I can test without extracting it from github?
- š§šŖBelgium tim-diels Belgium š§šŖ
Iām not behind my laptop but the link to the plain diff would be the same as a patch. So for now you could use https://git.drupalcode.org/project/mask/-/merge_requests/4.diff i guess?
The mask you can see in the screenshot as data-mask-value.
- š¦š¹Austria maxilein
Thank you.
I just wanted to make sure I am doing it right. That's what I did.
What did you put into the regex under admin/config/content/mask ? - š§šŖBelgium tim-diels Belgium š§šŖ
@maxilein It would be easier for me to help if you explain a bit more what you try to do...
Because I now I now used the default mask that are available in the module and these work. - š¦š¹Austria maxilein
Of course. Sorry.
I would like to enter numbers with thousand seperators "." and 2 digits behind a comma.
e.g. 1.000.000,34
And thank you for helping me. - š§šŖBelgium tim-diels Belgium š§šŖ
I'm not sure if that is possible with the default settings. You could maybe add a custom regex to support this. But I'm not a master in the regex.
But to me it seems the number support is working, except edge cases like yours will be difficult. - š¦š¹Austria maxilein
Well thank you.
But all you are saying it would theoretically be possible.So for my understanding:
1. apply you patch
2. find a complex regex for my use case
3. enter the regex - where exactly?
4. apply something to a field
5. test...Could you please help me with one more thing?
Help me get clear on the steps 3+4. If it easy for you screenshots would help a lot.
I can then once I understand everything use them to complete the documentation for mask module.Thank you.
- š§šŖBelgium tim-diels Belgium š§šŖ
I guess you need to add the regex at
/admin/config/content/mask
See:And then apply the regex to the field at the form settings, ex:
/admin/structure/types/manage/article/form-display
I really don't know if this works, I am really only a co-maintainer and not expert on this side.
But it should help you get started to see if you can get your edge case working.A simple one would be to set a pattern on a decimal field:
- š¦š¹Austria maxilein
Thank you.
I tried all kinds of masks:
mask 999.99 works:
234.44
234.5 -> 234.50mask 999,999.99
can only enter 3 digits then the field is emptied.mask 999 999.99
can only enter 3 digits then the field is emptied.I could not get any for larger numbers to work.
I saw that Mask Field module uses the jQuery Mask Plugin by Igor Escobar.
https://igorescobar.github.io/jQuery-Mask-Plugin/
There is a money mask already part of that. That would solve all the problems.
How can this be included?If I enter the mask 000.000.000.000.000,00 from the documentation $('.money').mask('000.000.000.000.000,00', {reverse: true}) and set reverse to true; I can only enter 2 digits before the field gets cleared.
If I don't set to reverse, I can enter 234.234 before the field is cleared.So there is clearly something in the code of the mask module that prevents these kind of masks. It seems to be some kind of loop that cannot run more than once (each time the second time a separator or comma is hit, it's over...)
But since the money format is there, it cannot be too difficult to enable it. It would be such a great improvement for drupal as a whole.
- š¦š¹Austria maxilein
The https://igorescobar.github.io/jQuery-Mask-Plugin/docs.html library already provides 2 money masks out of the box:
$('.money').mask('000.000.000.000.000,00', {reverse: true});
$('.money2').mask("#.##0,00", {reverse: true});It would be great to just be able to use them. For instancy with the symbol "money".
I tried to find a place. But I do not know where to look in the code. - š¦š¹Austria maxilein
Testing with #.##0,00
-> allows only 2 digitsTesting with # ##0.00
-> allows only xxx.xxIt seems that "," and " " cause the validation code to abort.
- š¦š¹Austria maxilein
I saw that webform seems to be using a different library but already provides a currency mask.
https://drupal.stackexchange.com/questions/309510/webform-custom-input-mask
Webform also provides some great examples in /modules/webform_examples/config/install/webform.webform.example_input_masks.yml.This is the library they use. And it seems that library can be use JS only.
https://github.com/RobinHerbots/Inputmask