Search code examples
jqueryjquery-pluginsmaskmasking

how to define an acceptable range of values using jquery mask plugin


How to define an acceptable range of values (0-9999)?

if mask is defined as

.mask('9999')

acceptable values will be in range from 1000 to 9999 but I need values between 0 and 9999


Solution

  • try with

    .mask('9?999')
    

    From http://digitalbush.com/projects/masked-input-plugin/

    You can have part of your mask be optional. Anything listed after '?' within the mask is considered optional user input.