I have taken this code here from the forum, but I have doubts about using it with negative numbers.
The user needs to enter 1 ° the negative sign and then the numbers. Some results will be negative others, so I needed a way for the user to type the signal first and then the numbers.
Follow the code below:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.13.4/jquery.mask.min.js"></script><scriptlanguage="javascript" type="text/javascript">
$('.numerico').mask('#.##0', {
reverse: true,
translation: {
'#': {
pattern: /-|\d/,
recursive: true
}
},
onChange: function(value, e) {
e.target.value = value.replace(/(?!^)-/g, '').replace(/^,/, '').replace(/^-,/, '-');
}
});
</script>