I have a RadComboBox that triggers some Javascript which changes a MaskedTextBox's mask from a 10-digit phone number to a 30-digit free-form mask. This behaves fine when testing under desktop browsers such as Chrome, but when I test it using mobile browsers on iOS and Android devices I get strange behavior. This occurs if I select the first option:
Using Chrome under Android (on a Samsung Galaxy S5 running Android 5.1), when setting focus on the MaskedTextBox, when I start typing on it the first value is ignored and the second value is added to the input field. If I try to edit the value I entered, the cursor jumps to the right side of the object and sometimes can't delete values and seems to get stuck.
Using Safari under iOS on an iPhone, everything seems to work properly except when focusing outside of the MaskedTextBox and giving it focus again, it pads the value entered with empty spaces.
I isolated the code below. Am I doing something wrong or is this an issue with the MaskedTextBox control under mobile browsers?
I'm using UI for ASP.NET AJAX Q2 2016 for the 4.5 .NET Framework.
Thank you:
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadScriptBlock
runat
=
"server"
ID
=
"RSBlock"
>
<
script
type
=
"text/javascript"
>
//
<![CDATA[
function rcbType_ClientIndexChanged(sender, eventArgs) {
var selectedItem = eventArgs.get_item();
switchMask(selectedItem.get_value());
}
function switchMask(selectedValue) {
var rtxtNumber = $find("<%= rtxtNumber.ClientID%>");
var masks;
switch (selectedValue) {
case '0':
var rtxtNumberResource1Label = 'Enter Order Number';
$get(rtxtNumber._wrapperElementID).getElementsByTagName("label")[0].innerHTML = rtxtNumberResource1Label;
rtxtNumber.set_enabled(true);
rtxtNumber.enable();
masks = [
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(), new Telerik.Web.UI.RadFreeMaskPart(),
];
rtxtNumber._length = 0;
rtxtNumber._setMask(masks);
rtxtNumber.clear();
break;
case '1':
rtxtNumber.set_visible(true);
var rmtbNumberResource1Label = 'Enter Phone Number';
$get(rtxtNumber._wrapperElementID).getElementsByTagName("label")[0].innerHTML = rmtbNumberResource1Label;
rtxtNumber.set_enabled(true);
rtxtNumber.enable();
masks = [
new Telerik.Web.UI.RadLiteralMaskPart('('),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadLiteralMaskPart(') '),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadLiteralMaskPart('-'),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadDigitMaskPart(),
new Telerik.Web.UI.RadDigitMaskPart()
];
rtxtNumber._length = 0;
rtxtNumber._setMask(masks);
rtxtNumber.clear();
break;
default:
rtxtNumber.set_enabled(false);
rtxtNumber.disable();
break;
}
}
//]]>
</
script
>
</
telerik:RadScriptBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
telerik:RadComboBox
ID
=
"rcbType"
runat
=
"server"
Label
=
"Order Number or Phone Number?"
CausesValidation
=
"false"
Width
=
"100%"
Height
=
"200px"
EmptyMessage
=
"Select one"
AllowCustomText
=
"true"
OnClientSelectedIndexChanged
=
"rcbType_ClientIndexChanged"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"Order Number"
Value
=
"0"
/>
<
telerik:RadComboBoxItem
Text
=
"Phone Number"
Value
=
"1"
/>
</
Items
>
</
telerik:RadComboBox
>
<
br
/><
br
/>
<
telerik:RadMaskedTextBox
ID
=
"rtxtNumber"
runat
=
"server"
Label
=
"Enter Order Number"
Width
=
"100%"
Enabled
=
"False"
Mask
=
""
/>
</
div
>
</
form
>
</
body
>
</
html
>