[CLOSED] Input Mask for textfield

  1. #1

    [CLOSED] Input Mask for textfield

    Hi,

    I need to apply input mask (maskRe) onto a text field at runtime.
    I mean sometimes the field may accept 3 numbers+2 characters, other time it might accept only 5 numbers and some other times it might accept 10 alpha numeric values.

    Basically, i need to replicate the same functionality provided by Visual Foxpro INPUTMASK property.

    I know that we might use MASKRE to do some of the stuff, but when i apply MASKRE at runtime from codebehind, it is not reflected in UI.

    Please help!!
  2. #2

    RE: [CLOSED] Input Mask for textfield

    Hi,

    Please note that MaskRe filters current inputed char only, it doesn't check whole text. Therefore I don't think that you can mask 3 numbers+2 characters


    To set MaskRe during DirectEvent please use


    TextField1.Set("maskRe", new JRawValue("/[0-9]/"));

    or update from SVN and use


    TextField1.MaskRe = "[0-9]";
  3. #3

    RE: [CLOSED] Input Mask for textfield

    Hi,

    Please find following sample to recreate the scenario.

    
    
    
    
    <%@ Page Language="VB"%>
    
    
    <%@ Import Namespace="Coolite.Ext.Web"%>
    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <script type="text/javascript">
    
    
    </script>
    
    
    <script runat="server">
    
    
    
    
    
    Protected Sub AssignMask_click(ByVal sender As Object, ByVal e As AjaxEventArgs)
    
    
    TextField2.Attributes.Add("maskRe", TextField1.Text)
    
    
    'TextField2.Reset()
    
    
    End Sub
    
    
    
    
    
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    
    
    <head runat="server">
    
    
    <title>Untitled Page</title>
    
    
    </head>
    
    
    <body>
    
    
    <form id="form1" runat="server">
    
    
    
    
    
    <ext:ScriptManager ID="ScriptManager1" runat="server">
    
    
    </ext:ScriptManager>
    
    
    <ext:Label ID="Label1" runat="server" Text="Input Mask">
    
    
    </ext:Label>
    
    
    <ext:TextField ID="TextField1" runat="server">
    
    
    </ext:TextField>
    
    
    <br />
    
    
    <ext:Label ID="Label2" runat="server" Text="New Masked Text">
    
    
    </ext:Label>
    
    
    <ext:TextField ID="TextField2" runat="server">
    
    
    </ext:TextField>
    
    
    <ext:Button ID="Button1" runat="server" Text="Assign Mask">
    
    
    <AjaxEvents>
    
    
    <Click OnEvent="AssignMask_click" />
    
    
    </AjaxEvents>
    
    
    </ext:Button>
    
    
    
    
    
    
    </form>
    
    
    </body>
    
    
    </html>

    There is no mask assigned on load to "TextField2".
    What i want is when user inputs "/[0-9]/" in TextField1 text, and clicks on "Assign Mask".

    The mask should be assigned to TextField2 at runtime, and it should only accept the numeric characters.

    There is not TextField2.Set() available, so i tried setting attribute for the same. But of no help!!

    Thanks,
    Hari
  4. #4

    RE: [CLOSED] Input Mask for textfield

    Hi,

    1. You have to set initial MaskRe otherwise field will not listen keys input. For example, set MaskRe="." (all characters are possible)
     <ext:TextField ID="TextField2" runat="server" MaskRe=".">
    2. If you use 0.8.2 (my previous post works with 1.0 only) then use during AjaxEvent
    TextField2.AddScript("{0}.maskRe = /{1}/;", TextField2.ClientID, TextField1.Text)

Similar Threads

  1. Replies: 4
    Last Post: Apr 25, 2012, 11:57 AM
  2. [CLOSED] TExtField mask
    By ViDom in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 03, 2012, 3:28 PM
  3. input text mask with L literal char
    By Wirianto Widjaya in forum 1.x Help
    Replies: 4
    Last Post: Mar 30, 2012, 6:35 AM
  4. [CLOSED] Mask for a textfield
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 26, 2011, 6:02 PM
  5. Replies: 10
    Last Post: Aug 31, 2008, 5:36 PM

Posting Permissions