Koba
Koba

Reputation: 125

jQuery Mask Plugin range of two numbers

I'm using jQuery Mask Plugin v1.14.16 in my web application. I'm trying to make two input mask, one that allows numbers from 4000 to 4999 and another one that allows numbers from 0 to 359. The plugin isn't working correctly, I suppose I'm using it not properly.

$('#range-field').mask('ZZZZ', {
    clearIfNotMatch: true,
    translation: {
      'Z': {
         pattern: /(4[0-8][0-9]{2}|49[0-8][0-9]|499[0-9])/
      }
    },
    placeholder: "from 4000 to 4999"
});

$('#angle-field').mask('ZZZ', {
    clearIfNotMatch: true,
    translation: {
      'Z': {
        pattern: /([0-9]|[1-8][0-9]|9[0-9]|[12][0-9]{2}|3[0-4][0-9]|35[0-9])/
      }
    },
    placeholder: "from 0 to 359"
});

JSFIDDLE

Upvotes: 1

Views: 257

Answers (0)

Related Questions