MaskedTextBox - UnmaskOnPost

1 Answer 206 Views
MaskedTextBox
Taras
Top achievements
Rank 3
Iron
Iron
Veteran
Taras asked on 18 Nov 2021, 07:42 PM

What is the usage of UnmaskOnPost?
It seems that if the value is true or false the unmasked text is passed to the ViewModel/Model/Controller.

I need the masked value to be passed for additional validation.

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 19 Nov 2021, 03:29 PM

Hi Taras,

In general the purpose of the .UnMaskOnPost() is to specify whether the input value of the component will be unmasked or not on form post. If set to true the input will not have mask rules applied. For example:

 @(Html.Kendo()
    .MaskedTextBox()
    //additional configuration
    .Value("555 123 4567")
    .UnmaskOnPost(true)
    .Mask("(999) 000-0000")
)

In this scenario, the input value on form post would be "5551234567"  instead of "(555) 123-4567".

With that said, I have created a sample project which illustrates both scenarios of the .UnmaskOnPost() configuration. Whilst retrieving the input values on form post in the following Action Method:

[HttpPost]
public IActionResult Index(string maskedBoxWithoutMask, string maskedBoxWithMask)
{
    return View();
}

Finally, I am attaching the sample project for you to review.

If this example does not help, please consider providing additional details about the configuration you currently have. Or, if it is possible, try to reproduce the issue you are facing in the provided sample.

 

Regards,
Alexander
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Taras
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 24 Nov 2021, 06:27 PM

Hi Alexander,

Sorry for late reply.  Life got in the way.

I can confirm that the it works as expected in your example.

There is some other issue in the application.

Thanks

Alexander
Telerik team
commented on 25 Nov 2021, 01:11 PM

If the issue remains unresolved and you think it is relevant to the MaskedTextBox component consider reproducing it in an isolated environment. For example in a Telerik REPL with the component's configuration. Or if possible try to reproduce it in the sample previously sent.

Taras
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 05 Dec 2021, 03:55 PM

Issue seems to be that the client had an older version of Kendo UI.  Using latest version eliminated the problem
Tags
MaskedTextBox
Asked by
Taras
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Alexander
Telerik team
Share this question
or