MVC5 Classic
Require Letters

The wijinputmask widget allows you to create a mask that requires users to enter letters, for example, in an input box for a user name. Use the L masking element for the mask option to take advantage of this feature. See the InputMask  > First Name sample of the MVC Control Explorer live demo at http://demo.componentone.com/ASPNET/MVCExplorer/inputmask/FirstName.

  1. Create an C1 ASP.NET MVC 5 Web Application.In the Solution Explorer, expand the Views | Shared folder and double-click _Layout.cshtml to open the file.
  2. Add the following markup within the <body> tags of the page.
    <input type="text" id="textbox1" />
          <h6>Mask</h6>
          <p> >L|LLLLLLLLL</p>
    </div>
    
  3. After the closing </div> tags you added in the previous step, enter the following jQuery script to initialize the wijinputmask widget and set the mask option. Using an L as the masking element requires that a letter is entered. In this case, 10 letters can be entered. The >L| ensures the first letter is capitalized and the letters that follow are lowercase, unless the Shift key is used to capitalize other letters.
    <script id="scriptInit" type="text/javascript">
        $(document).ready(function () {
            $("#textbox1").wijinputmask(
                    {
                      mask: '>L|LLLLLLLLL',
                      hidePromptOnLeave: true
                    });
        });
          </script>
    
  4. Press F5 to run the application and enter a name.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback