We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MaskedTextBoxFor optional mask elements

Thread ID:

Created:

Updated:

Platform:

Replies:

140826 Nov 8,2018 02:19 PM UTC Nov 14,2018 06:46 AM UTC ASP.NET Core - EJ 2 5
loading
Tags: MaskedTextbox
Phil
Asked On November 8, 2018 02:19 PM UTC

Hello

I am using EJ 2 version 16.3.0.29 (nuget package).

When using a MaskedTextBoxFor in a form I noted some strange behaviour.

1: Optional mask element is returned in value
When I use a MaskedTextBoxFor and define the mask as "\\+00\\ 9999999999", it is displayed in the GUI as "+__ __________". 
Let's assume, a user inputs "+11 111111111" (1 number less than the maximum number of allowed numbers).
When the form is submitted, the value of the parameter sent in the MaskedTextBox is "+11 111111111_".
I would assume that the "_" at the end is not added to the value, since it was defined as optional in the mask.

Is this a bug?
Is there an option to NOT include the optional mask elements that were not filled when getting the value?


2: Option to hide optional mask elements in the GUI
Is it possible to hide the optional characters in the mask's prompt?
E.g. the mask is defined as "\\+00\\ 0000000009", in the GUI it is displayed as "+__ __________" (note that the optional character is displayed as a "_" as well).
Now I would assume that the optional character's would not be displayed at all, or at least with another character, to indicate to the user that the character is optional.

Is there an option to hide the optional mask elements when displaying the mask in the GUI?


Thank you for your help.

Kind regards
Phil

Christopher Issac Sunder K [Syncfusion]
Replied On November 9, 2018 11:36 AM UTC

Hi Phil, 

Thank you for contacting Syncfusion support. 

Here are the answers for your queries, 

1: Optional mask element is returned in value 
 
You can use the value property to get or set the values in MaskedTextBox. This property does not contains any mask values. Please check the below screen shot. 

 

If you want the MaskedTextBox GUI value, you can use the getMaskedValue method.  

2.Option to hide optional mask elements in the GUI 
 
You can use the promptChar option to hide the _ character on MaskedTextBox. For this scenario, you need to specify the promptChar value as space(“ ”). Please find the below code block, 

<ejs-maskedtextbox id="mask4" mask="\\+00\\ 9999999999" promptChar=" "></ejs-maskedtextbox> 

Please let us know if you need any further assistance. 

Thanks, 
Christo

Phil
Replied On November 9, 2018 12:47 PM UTC

Thank you for your reply.


1: Optional mask element is returned in value
As I said, I use the MaskedTextBoxFor, thus the value is automatically bound to the model.
When I inspect the model on the server, then the property contains the "_" value that was optional.


2: Option to hide optional mask elements in the GUI
Your suggestion would make all prompted characters invisible.
I would like to only make the optional characters invisible. The mandatory characters should still be visible.
Is there a way to achieve this?


Christopher Issac Sunder K [Syncfusion]
Replied On November 12, 2018 12:43 PM UTC

Hi Phil, 

Thanks for the update. 

1: Optional mask element is returned in value 
 
In our previous update, we have provided the possibilities for getting the values in MaskedTextBox with client side. Based on your needed MaskedTextBox value(using value property or else using getMaskedValue method), you can manually pass the value to server side by using XMLHttpRequest and use it. 

2.Option to hide optional mask elements in the GUI   

If we specify the mask value “9”, we should specify the value as either number or else space. If we are not specifying the value, it will be considered as non-applied masked value(promptChar(default value _)).  
The optional value of mask is not literally optional but it denotes that we should specify any of the character such as Letter or space, Number or space. 

Please let us know if you have any concerns. 

Thanks,
Christo


Phil
Replied On November 13, 2018 11:57 AM UTC

Thank you for your reply.

This issue is solved, I can live with the provided answers.

Just for the record, I would like to note that I think it is a bug that the server receives the optional characters when using the MaskedTextBoxFor control.It defeats the purpose of the ...For control, if I have to manually adapt the value before sending it to the server.


Christopher Issac Sunder K [Syncfusion]
Replied On November 14, 2018 06:46 AM UTC

Hi Phil, 

Thanks for the update. We are glad to hear that the issue got resolved at your end.  

Regarding your query about For control, The solution is applicable for both MaskedTextBoxFor and MaskedTextBox because we have stored the MaskedTextBox UI value(with Optional character) in our end and then explore the value to server side. So, for your requirement, you can manually adapt the value before sending it to the server side for both MaskedTextBox and MaskedTextBoxFor components.  

Please let us know if you need any further assistance. 

Thanks,
Christo


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;