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

IPv4 Address regex mask

1 Answer 470 Views
MaskedTextBox
This is a migrated thread and some comments may be shown as answers.
Emin Inam
Top achievements
Rank 1
Emin Inam asked on 24 Feb 2017, 12:09 PM

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>

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 28 Feb 2017, 09:37 AM
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.
Tags
MaskedTextBox
Asked by
Emin Inam
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or