Dialog.MaskedInput

table Dialog.MaskedInput ( 

string  Title = "",

string  Prompt,

string  Mask,

string  DefaultText = "",

number  Icon = MB_ICONQUESTION,

string  PlaceHolder = " " )

Example 1

postal_code = Dialog.MaskedInput("", "What is your Postal Code?", ">#> #>#", "", MB_ICONQUESTION, " ");

Asks the user for their postal code, making sure that they enter it in the correct format (three capital letters, three numbers, and a space, like this: A9A 9A9), and stores the result in table called postal_code. The raw data can be accessed by referencing postal_code.Data and the string as it was displayed can be accessed by referencing postal_code.Displayed.

Example 2

-- Set the flag variable.
pass = false;

while (not pass) do
    -- Prompt the user for their telephone number.
    phone = Dialog.MaskedInput("Personal Information", "Please enter your telephone number:", "(###) ###-####", "##########", MB_ICONQUESTION, "#");

    -- If there wasn't an error and the user didn't cancel, try to validate the number.
    if (phone ~= nil) then
        -- Search for the placeholder character "#".
        search_result = String.Find(phone.Data, "#", 1, false);

        -- If the placeholder character wasn't found...
        if (search_result == -1) then
            -- Display the telephone number in a dialog.
            Dialog.Message("Information", "The telephone number "..phone.Displayed.." will be entered in our records.", MB_OK, MB_ICONINFORMATION);

            -- Set the flag to exit the loop.
            pass = true;
        else
            -- Tell the user that the phone number entered was not complete.
            Dialog.Message("Notice", "The telephone number entered was not complete. Please re-enter the number.", MB_OK, MB_ICONINFORMATION);
        end
    else
        -- There was an error or the user cancelled. Exit the loop.
        pass = true;
    end
end

Prompts the user to enter their telephone number using the Dialog.MaskedInput action. In order to help the user enter the information, the telephone mask is used. The placeholder character and default text uses the "#" character. A validation is performed on the user input that checks for the "#" character signalling an incomplete number. If its found, the user is prompted to re-enter the information. The loop will only be exited if the user enters a valid telephone number, or cancels. If they enter a valid number, a dialog is shown with their number as it was displayed.

See also:  Related Actions