[CLOSED] What's the Razor syntax for InputMask?

  1. #1

    [CLOSED] What's the Razor syntax for InputMask?

    Tried, but could not convert this:

    <ext:TextField runat="server" FieldLabel="Custom placeholders" Note="Input a date">
                        <Plugins>
                            <ext:InputMask runat="server" Mask="dt/mn/yzzz">
                                <MaskSymbols>
                                    <ext:MaskSymbol Name="d" Regex="[0123]" Placeholder="d" />
                                    <ext:MaskSymbol Name="t" Regex="[0-9]" Placeholder="d" />
                                    <ext:MaskSymbol Name="m" Regex="[01]" Placeholder="m" />
                                    <ext:MaskSymbol Name="n" Regex="[0-9]" Placeholder="m" />
                                    <ext:MaskSymbol Name="y" Regex="[12]" Placeholder="y" />
                                    <ext:MaskSymbol Name="z" Regex="[0-9]" Placeholder="y" />
                                </MaskSymbols>
                            </ext:InputMask>
                        </Plugins>
                    </ext:TextField>
    to Razor format.

    Help...
    Last edited by Daniil; Sep 26, 2013 at 5:17 AM. Reason: [CLOSED]
  2. #2
    Hi @AmitM,

    Here you are.

    Example
    @(Html.X().TextField()
        .Plugins(X.InputMask()
            .Mask("dt/mn/yzzz")
            .MaskSymbols(symbols =>
                {
                    symbols.Add(new MaskSymbol() { Name = "d", Regex = "[0123]", Placeholder = 'd' });
                    symbols.Add(new MaskSymbol() { Name = "t", Regex = "[0-9]", Placeholder = 'd' });
                    /* the rest symbols */
                }
            )
        )
    )
  3. #3

    I'm doing something wrong...

    I need to use this as an input mask for time. In the DB, I have values as a string with a format necessary for a seperate export function.

    An example time is "05:00 PM". They are all stored as string per requirements.

    I am using this for the input mask:
    .Plugins(Html.X().InputMask()
                                        .Mask("hH:mM aM")
                                        .ClearWhenInvalid(false)
                                        .MaskSymbols(symbols =>
                                            {
                                                symbols.Add(new MaskSymbol() { Name = "h", Regex = "[01]" });
                                                symbols.Add(new MaskSymbol() { Name = "H", Regex = "[0-9]" });
                                                symbols.Add(new MaskSymbol() { Name = "m", Regex = "[0-5]" });
                                                symbols.Add(new MaskSymbol() { Name = "M", Regex = "[0-9]" });
                                                symbols.Add(new MaskSymbol() { Name = "a", Regex = "[aApP]" });
                                            }
                                        )
                                    )
    It works fine when the field is blank. However, when the field is already populated from the DB, the field goes blank as soon as I click in it to edit.

    Am I missing some property?

    Thanks,
    Amit
  4. #4

    Got it

    I was missing

    .AllowInvalid(true)

Similar Threads

  1. [ASK] tabPanel.add razor syntax
    By 4L4Y in forum 2.x Help
    Replies: 2
    Last Post: May 21, 2013, 9:29 AM
  2. [CLOSED] autocomplete example with razor syntax ?
    By zwf in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 19, 2012, 3:56 PM
  3. MVC 4 razor syntax and remotevalidation problem
    By ITReppert in forum 2.x Help
    Replies: 7
    Last Post: Sep 10, 2012, 3:05 PM
  4. [CLOSED] Razor syntax inside Ext Controls
    By mcfromero in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 08, 2012, 7:29 PM
  5. [CLOSED] DropTarget Not working in razor syntax
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 30, 2012, 11:08 AM

Tags for this Thread

Posting Permissions