exclude 0 as first character

3 posts, 0 answers
  1. Reine
    Reine avatar
    2 posts
    Member since:
    Mar 2015

    Posted 18 Aug Link to this post

    I have a five digit postal code and want to exclude zero as first character and only allow numeric values.

    Html.Kendo().MaskedTextBoxFor(a => a.Postnummer)
                        .Rules(rules => { rules.Add('0', "/[1-9]/"); })


    not working, cant type in 0 at all.

  2. Orlin
    Orlin avatar
    19 posts

    Posted 19 Aug Link to this post

    Hello Reine,

    To achieve your goal you need to use a custom mask rule. Learn more about these here:


    The code for not allowing zero as the first digit will look similar to the following:

    Html.Kendo().MaskedTextBoxFor(a => a.Postnummer)
                        .Rules(rules => { rules.Add('~', "/[1-9]/"); })

    This allows only digits 1-9 for the first character and 0-9 for the rest. The 0 is a predefined mask rule. You can see a list at the following URL:


    I hope this helps.

    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX banner
  4. Reine
    Reine avatar
    2 posts
    Member since:
    Mar 2015

    Posted 19 Aug Link to this post

    Thanx worked like a charm :)
Back to Top