Reader
  • Home
  • About
  • Deals
  • Services
  • Contact

Format User Input to Match a Specified Pattern: For Web Forms

Last updated on November 19th, 2013 by Gabriel Livan

Sometimes it is useful to format user input as they type. It provides a better experience to the user, it shows that you care about visitor’s input and you optimized your web forms like a professional and this way, it’s very unlikely the user will make any typing mistakes as it clearly shows how the input format should be. Here are 2 scripts that you can use to improve the functionality of your forms:

Masket Input Plugin allows a user to easily type in fixed width input in which you would like them to enter the information in a certain format (dates,phone numbers,social security numbers etc). It’s been tested on Internet Explorer, Firefox, Safari, Opera, and Chrome. A mask is determined by a format made up of mask literals and mask definitions. Any character not in the definitions list below is considered a mask literal. Mask literals will be automatically entered for the user as they type and will not be able to be removed by the user.The following mask definitions are predefined:
a – Represents an alpha character (A-Z,a-z)
9 – Represents a numeric character (0-9)
* – Represents an alphanumeric character (A-Z,a-z,0-9)

jquery-mask-input-plugin-preview

  • Source & Demo: http://digitalbush.com/projects/masked-input-plugin/
  • Compatibility: Works in all CSS3 browsers and mobile devices


Formatter.js works in a similar way as the Masked Input Plugin. It was built from the ground up with no dependencies (great to use if you prefer RAW JavaScript applications). There is also a jQuery wrapper version for quick use, just in case.

Opts

  • pattern (required): String representing the pattern of your formatted input. User input areas begin with {{ and end with }}. For example, a phone number may be represented: ({{999}}) {{999}}-{{999}}. You can specify numbers, letters, or numbers and letters.
    • 9: 0-9
    • a: A-Za-z
    • *: A-Za-z0-9
  • persistent: [False] Boolean representing if the formatted characters are always visible (persistent), or if they appear as you type.

formatter.js-preview

  • Source: http://firstopinion.github.io/formatter.js/index.html
  • Demo: http://firstopinion.github.io/formatter.js/demos.html

Filed Under: JavaScript, jQuery

About Me

Gabriel LivanHey, there! I'm Gabriel Livan, Web Developer, Blogger and Internet Marketer. I love making fast, secure and scalable web applications, running and travelling around the world. I blog about WordPress, site speed & security and quality tools for web professionals. Read more

What are you looking for?

Categories

  • AJAX (22)
  • Deals (10)
  • Design (30)
  • eBooks (2)
  • Flash (19)
  • Freebies (11)
  • General (62)
  • Giveaways (1)
  • Graphics (27)
  • HTML & CSS (35)
    • Frameworks (9)
  • JavaScript (160)
    • Frameworks (8)
    • jQuery (89)
    • MooTools (14)
  • Page Loading Speed (2)
  • Photoshop (3)
  • PHP (113)
  • Reviews (8)
  • SEO (6)
  • Statistics (2)
  • Web Tools (13)
  • WordPress (27)
    • Plugins (15)
    • Snippets (4)
    • Tools (2)
    • Tutorials (6)

Copyright © 2026 · BitRepository.com - All Rights Reserved

  • Home
  • About
  • Contact