Dec 31, 2014, 4:21 AM
Brazilian phone number format
In brazil we have both 8-digit and 9-digit format, so i would like to provide an example of using InputMask to accomplish this requirement
Daniil, if you have nothing to add, please mark this thread as closed.
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">
var ProcessMask = function (item, newValue, oldValue) {
var newMask = null;
var eightDigitFormat = "(~~) ~999-9999?9";
var nineDigitFormat = "(~~) ~9999-9999";
if (item.inputMask.getUnmaskedValue().length < 11) {
newMask = eightDigitFormat;
}
else {
newMask = nineDigitFormat;
}
if (item.inputMask.mask != newMask) {
item.suspendEvents();
item.inputMask.setMask(newMask);
item.resumeEvents();
}
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:TextField FieldLabel="Brazilian Phone" AllowBlank="false" runat="server">
<Plugins>
<ext:InputMask Mask="(~~) ~999-9999?9" ClearWhenInvalid="false" runat="server">
<MaskSymbols>
<ext:MaskSymbol Name="~" Regex="[1-9]" />
</MaskSymbols>
</ext:InputMask>
</Plugins>
<Listeners>
<Change Fn="ProcessMask" />
</Listeners>
</ext:TextField>
</body>
</html>
Daniil, if you have nothing to add, please mark this thread as closed.
Last edited by RaphaelSaldanha; Jan 01, 2015 at 6:27 AM.