78964

jquery masked input plugin set value digits

Question:

$(".id").mask("999-99-9999-999-99");

I have the above mask input format i want to know if it is possible to have a predefined value for x number of characters like for example

I want the first 5 letters to have a default and unchangeable numbers.

Sample number will be

639-27-9999-999-99

here the numbers 639-27- should be always there meaning when the input has focus it will automatically be put there and cannot be changed.

F.Y.I

<a href="http://digitalbush.com/projects/masked-input-plugin/" rel="nofollow">Plugin</a>

Answer1:

A workaround solution might be,

$.mask.definitions["9"] = null; $.mask.definitions["^"] = "[0-9]"; $(".id").mask("639-27-^^^-^^^-^^"); <ol><li>remove the definition for 9 </li> <li>add a definition for numeric regex with a new key ex. ^</li> <li>use the new definition </li> </ol>

<a href="http://jsfiddle.net/dzqrr0qm/" rel="nofollow">fiddle</a>

hope this helps

Answer2:

You can do it like this using the plugin: $(".id").mask("639-27-9999-999-99"); As they used 9 as their number definition, you can change it in their source code with any other character.

Recommend

  • Are all immutable objects singleton instances? [closed]
  • Saving images to Iphone photo library
  • Alamofire and Reachability.swift not working on xCode8-beta5
  • Outlines on links in IE9 remains when focus is changed
  • How to getText() from the input field of an angularjs Application
  • Reading a file into a multidimensional array
  • Differences in dis-assembled C code of GCC and Borland?
  • How to assign byte[] as a pointer in C#
  • Android application: how to use the camera and grab the image bytes?
  • Button click event not firing in jQuery
  • Unable to decode certificate at client new X509Certificate2()
  • Excel's Macro-Recorder usage
  • How to handle images sent by a mobile device?
  • Textfile Structure (tables)
  • java inputstream
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • How to render a blob on a canvas element?
  • How to clear text inside text field when radio button is select
  • How to use an array of arrays with array_map(…) in PHP?
  • FFmpeg Conversion Error
  • Scrapy recursive link crawler
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Splitting given String into two variables - php
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • swift auto completion not working in Xcode6-Beta
  • AES padding and writing the ciphertext to a disk file
  • Excel - Autoshape get it's name from cell (value)
  • Updating server-side rendering client-side
  • Modifying destination and filename of gulp-svg-sprite
  • How to extract text from Word files using C#?
  • what is the difference between the asp.net mvc application and asp.net web application
  • Build own AppleScript numerical error handling
  • Apache 2.4 - remove | delete | uninstall
  • GridView Sorting works once only
  • Matrix multiplication with MKL
  • Binding checkboxes to object values in AngularJs