MaskedTextBox and single regular expression

3 posts, 0 answers
  1. Henk
    Henk avatar
    5 posts
    Member since:
    May 2013

    Posted 05 May 2015 Link to this post

    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. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 07 May 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Henk
    Henk avatar
    5 posts
    Member since:
    May 2013

    Posted 19 May 2015 in reply to Georgi Krustev Link to this post

    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

Back to Top