This is a migrated thread and some comments may be shown as answers.

MaskedTextBox and single regular expression

2 Answers 180 Views
MaskedTextBox
This is a migrated thread and some comments may be shown as answers.
Henk
Top achievements
Rank 2
Henk asked on 05 May 2015, 09:53 AM

Hi all,

Is it possible to use a single regular expession for the masked text box? I have the problem that I want to set the mask for a country-dependent IBAN entry field. The regular expression for Norway, for instance, would be '/^NO[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{1}$/'  while for Romania it would be '/^RO[0-9]{2}[A-Z]{4}[A-Za-z0-9]{16}$/'. They are different in length, different in where there should be letters or digits, etc. I cannot think of a way to easily change the mask/custom rules during runtime. Just setting a single regex would do the trick quickly and easily, if it is supported that is.

 

Regards,

Henk

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 07 May 2015, 07:19 AM
Hello Henk,

The MaskedTextBox is designed to use a regular expression for each character, but widget's mask, however, cannot be a single regular expression. What I can suggest you is to update the mask on runtime using setOptions based on the culture setting that user has chosen:
maskedtextbox.setOptions({
  mask: "{{new mask}}"
});
If single expression is the only way you can go, then I suppose that you can use the input pattern attribute.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Henk
Top achievements
Rank 2
answered on 19 May 2015, 08:42 AM

Hi Georgi,

Sorry for my belated reply and thanks for your response. I decided to use setOptions to switch between a generic IBAN mask and a non-IBAN account mask (= no mask at all). I suppose I could create a mask on the fly based on the single regex but I'll leave that for a later time.

Best regards,

Henk

Regards,

Henk

Tags
MaskedTextBox
Asked by
Henk
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Henk
Top achievements
Rank 2
Share this question
or