I’m trying to add a inputmask to an input element which allows the user to enter a decimal between -90 and 90 with 0 to 4 numbers after the decimal separator (side note: I’m using jQuery validate for min & max value validation).
I was able to make it work for positive values using this code:
$("#id").inputmask("99,9{0,4}");
I tried to extend it to allow negative values with the following code:
$.mask.definitions['~']='[+-]';
$("#id").inputmask("~99,9{0,4}");
Which did not work; The value started always with a “–“ and it was not possible to replace it with a “+” or to remove it.
My last try was this:
$('#id').inputmask('decimal', {
radixPoint: ".",
integerDigits: 2,
digits: 4,
digitsOptional: true,
autoGroup: true,
allowPlus: true,
allowMinus: true
});
This works almost, but I have the following problems:
My goal is to have an input element with a visible mask, preferably in the following format __.____, which allows the user to enter negative or positive values. The user should be able to add a minus sign to the start of the input (after (and before) he entered the number).
Edit: Added fiddle JSFiddle
I’m trying to add a inputmask to an input element which allows the user to enter a decimal between -90 and 90 with 0 to 4 numbers after the decimal separator (side note: I’m using jQuery validate for min & max value validation).
I was able to make it work for positive values using this code:
$("#id").inputmask("99,9{0,4}");
I tried to extend it to allow negative values with the following code:
$.mask.definitions['~']='[+-]';
$("#id").inputmask("~99,9{0,4}");
Which did not work; The value started always with a “–“ and it was not possible to replace it with a “+” or to remove it.
My last try was this:
$('#id').inputmask('decimal', {
radixPoint: ".",
integerDigits: 2,
digits: 4,
digitsOptional: true,
autoGroup: true,
allowPlus: true,
allowMinus: true
});
This works almost, but I have the following problems:
My goal is to have an input element with a visible mask, preferably in the following format __.____, which allows the user to enter negative or positive values. The user should be able to add a minus sign to the start of the input (after (and before) he entered the number).
Edit: Added fiddle JSFiddle
$("input.percentage").inputmask({
alias: "percentage",
digits: "2",
rightAlign: false,
suffix: "%",
integerDigits: 5,
digitsOptional: true,
allowPlus: true,
allowMinus: true,
placeholder: "0",
min: -1000,
max: 1000,
numericInput: true
});
I used max and min to allow minus for the input with two decimal points.