0
I have a problem comparing values of two fields input
.
I want an action to happen if the value being inserted is less than the value of the input
occult.
Imagine that the value of the previous one has to be lower than the value of the field I’m entering at the moment, and the value of the previous one is 8594. If you insert 85939 it considers this value lower than the previous.
Look at the code:
<div class="form-group">
<label for="formGroupExampleInput2">Contador Atual</label>
<br />
Valor Anterior: <span class="anterior">8594</span>
<input type="hidden" class="vant" value="8594">
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Introduzir Valor Do Contador">
$('input[type="text"]').blur(function() {
var campoV = $(this).parent().find('.anterior');
var thisvalue = $(this).val();
var anteriorValue = $(this).parent().find('.vant').val();
if(thisvalue < anteriorValue) {
campoV.css("color", "red");
} else{
campoV.css("color", "black");
//insere valor na base de dados!!
}
});