-1
Guys, I have a form where I have a field to type in values. This field has a mask in jquery that formats the values for Brazilian real 0.00, mvalor function, which is below, but this field can only accept values in real greater than 25.00, or it is necessary to validate this field so that the user can only enter values greater than 25.00. A friend passes me this function below, it works well, if someone type a value less than 25,00 shows an error message warning and injects the value 25,00 in the input field, in this format in real, but if I type a value above 999,00, for example 1,000,00 an error happens because it understands that the entered value is less than 25.00, I realized that this occurs because the function checks only the numbers before the point, if before the point is greater than 25 regardless of whether it is real or numerical blz, but if someone type 1,000,00 which is less than 25,00, where the number before the point is only 1 so it does not do what is proposed and gives a mistake. If I type in the field 25.000,00 of the right, with that I realize that validates only the number that comes before the point, what comes after the function ignores.
I don’t have enough knowledge in jquery to fix this problem, if anyone can help me, I will be very grateful.
<script>
$('input[name=amount]').focusout(function() {
var valorDigitado = parseFloat($(this).val());
if (valorDigitado < 25.00) {
$('input[name="amount"]').val("25,00");
showError_amount();
} else {
$("#error_amount").hide();
}
});
function mvalor(i) {
var v = i.value.replace(/\D/g,'');
v = (v/100).toFixed(2) + '';
v = v.replace(".", ",");
v = v.replace(/(\d)(\d{3})(\d{3}),/g, "$1.$2.$3,");
v = v.replace(/(\d)(\d{3}),/g, "$1.$2,");
i.value = v;
}
</script>
Thanks for the help, it solved my problem.
– Paca