1
I took this code here from the forum, but I’m having doubts about using negative numbers.
The user needs to type 1° the negative sign and then the numbers. Certain results will be negative others will not, so it needed a way that the user could type first the sign and then the numbers.
Follows code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.13.4/jquery.mask.min.js"></script>
<script language="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>
Thank you Virgilio, it worked super well with this code. m/
– André Batista