1
I have this code that retrieves the value entered in the input and compares it with a value x, in this case 25.00. The problem is that when I change the field inside the form it shows the error saying that the entered value is less than 25, but if the person does not correct and submit the form he sends anyway, i need that if the entered value is less than 25 it shows the error message and when the user submits the form it returns to show the error not letting the form follow and when the user enters the correct value, ie 25 or higher, the error message disappears.
<div class="donate_amount_field m-0">
<input type="text" name="amount" class="form-control" value="" required>
</div>
<div class="alert" id="error_amount" style="display: none;">valor menor que 25</div>
$('input[name=amount]').blur(function() {
if ( $(this).val() < "25,00" )
showError_amount();
});
function showError_amount() {
$("#error_amount").show();
}
His help was of great value, but it lacked a detail that I forgot to mention, the field in question he has a mask that formats the value in Brazilian real 0,00 dai when I type a value even with the mask it shows the error message saying that the value is lower and puts 25 in the field and that’s where the problem is, it puts the value 25 but is not in the format 25,00, so if a user does not correct it will command in the format that the code puts which is 25 and so will give error in the request is what is missing this value be in the format 25,00, have to leave so, I tried to change here but did not give.
– Paca
I got it. I’ll tell you what. Copy here all html and js that you have (including this issue of the mask), because it is better for us to understand and be able to help you in the best way, quiet?
– André Albson
André thank you so much, for the help, I’ve already solved, just put this part of the code $('input[name="amount"]'). val(25.00); where this the 25.00 changed as string and put between "25.00", so it worked perfectly. Thanks again.
– Paca
Show brother. I’m glad you succeeded! Hugging.
– André Albson