Reputation: 179
I have this input (and i'm using JQuery Mask Plugin):
<input type="text" name="number" class="campo-formulario mascara-end-numero campo-numero perfil-input" id="perfil-numero" placeholder="Numero">
Which can only accept numbers, and the first number CAN'T be 0.
Using this, only numbers are accepted:
jQuery('.mascara-end-numero').mask('#');
Tried to define the "non-zero-at-first" rule using:
jQuery('.mascara-end-numero').mask('Z#', {
translation: {
'Z': {
pattern: /[1-9]/, optional: true
}
}
});
But it didn't work :/
How can it be done?
Upvotes: 0
Views: 1715
Reputation: 179
Solution (remove "optional"):
jQuery('.mascara-end-numero').mask('Z#', {
translation: {
'Z': {
pattern: /[1-9]/
}
}
});
Upvotes: 2