locked
Custom Format Mask for Textbox RRS feed

  • Question

  • User-1212693777 posted

    Hello,

    I am trying to create a custom format mask for a textbox (txtLotNo) that will force the user to enter a lot number in the textbox as follows:

    "1 - _ _ _ _ _ _ _".  Every Lot # should start with 1, then a dash, then seven placeholders where the user can enter numbers.  Is there a way to create this so the mask actually shows up in 

    the textbox as well?

    Many thanks in advance!

    Sunday, March 2, 2014 2:34 PM

Answers

  • User281315223 posted

    Basically, you'll define a specific template that you want to use which in your case will look something like this : 

    ## ## ## ##

    The '#' symbols will define your actual items that you need so as you type it will only fille those areas. If you wanted to use something like the DigitalBush Masking Plug-In, you would just need the following code : 

    <!DOCTYPE html>
    <html>
    <head>
    <!-- Example jQuery Reference -->
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <!-- Example jQuery Masking Script -->
    <script src="http://digitalbush.com/wp-content/uploads/2013/01/jquery.maskedinput-1.3.1.min_.js"></script>
    <meta charset=utf-8 />
    <title>JS Bin</title>
      <script type='text/javascript'>
        $(function(){
            //Define your mask (using 9 to denote any digit)
            $('#YourTextBox').mask('1-9999999');
        });
      </script>
    </head>
    <body>
        <!-- Example of your TextBox -->
        <asp:TextBox ID="YourTextBox" runat="server"></asp:TextBox>
    </body>
    </html>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 2, 2014 4:21 PM