IPv4 Address regex mask

2 posts, 0 answers
  1. Emin Inam
    Emin Inam avatar
    6 posts
    Member since:
    Oct 2004

    Posted 24 Feb Link to this post

    Hello,

    I need to validate user input for ipv4 adress. I am using maskedtextbox. How can i set mask property of maskedtextbox?

    I write this code but it doesn't work. ?

    <body>
     
    <input id="maskedtextbox" />
    <script>
    $("#maskedtextbox").kendoMaskedTextBox({
        mask: "~",
        rules: {
            "~":((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
        }
    });
    </script>
    </body>

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1799 posts

    Posted 28 Feb Link to this post

    Hello Emin,

    I am afraid that there is currently no built-in rule for IP addresses. However, you can implement the behavior with a bit of additional logic. You can define the MaskedTextBox as below:

    $("#maskedtextbox").kendoMaskedTextBox({
        mask: "000.000.000.000",
          
    });

    Then, you would need to validate the input. For that you can use the Validator component and specify a custom rule.

    Check out the following example for illustration.



    Regards,
    Viktor Tachev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top