PDA

View Full Version : [CLOSED] InputMask plugin



luiz
Jul 25, 2013, 5:31 PM

Baidaly
Jul 26, 2013, 12:54 AM
Hello!

Please, read the following post: http://forums.ext.net/showthread.php?23858&p=104436&viewfull=1#post104436

luiz
Jul 26, 2013, 6:40 PM
Hi,

Yes, in this case he wanted to force the filling, in my case I do not.
In my scenario the user can leave the field empty.
Is there some setting?

Guess I'll have to validate all form fields (foreach) manually.

Thanks!

Baidaly
Jul 26, 2013, 9:57 PM
Try the following overriding:



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server"></ext:ResourceManager>

<script>
Ext.override(Ext.net.InputMask, {
getErrors: function () {
var field = this.getCmp(),
errors = this.fieldGetErrors.call(field, field.processRawValue(field.getRawValue()));

if (errors.length == 0 && field.getRawValue().length == 0 && field.allowBlank)
return errors;

if (!this.isValueValid()) {
errors.push(this.invalidMaskText || field.invalidText);
}

return errors;
},
});
</script>

<ext:FormPanel runat="server" ID="FormPanel1">
<Items>
<ext:TextField ID="TextFieldTelefoneFixo" runat="server" FieldLabel="Telefone fixo" AllowBlank="true" MsgTarget="Side">
<Listeners>
<Change Handler=""></Change>
</Listeners>
<Plugins>
<ext:InputMask ID="InputMaskTelefoneFixo" runat="server" Mask="(99) 9999-9999" InvalidMaskText="Formato incorreto">
<CustomConfig>
</CustomConfig>
</ext:InputMask>
</Plugins>
</ext:TextField>
</Items>
<Buttons>
<ext:Button ID="BotaoSalvarUsuario" runat="server" Text="Salvar" Icon="DiskBlack">
<Listeners>
<Click Handler="
Ext.Msg.alert(#{FormPanel1}.getForm().isValid().to String());
"></Click>
</Listeners>
</ext:Button>
</Buttons>
</ext:FormPanel>
</form>
</body>
</html>

luiz
Jul 26, 2013, 11:00 PM
Hi Baidaly,

Please, close this thread.

Thanks for the solution.