I have an input text for checking if the corrected values are coming or not in alert
. But when I open the form and change some value to check whether it takes the updated value in alert. It shows me the old value in alert.
Here is the code
$('#spnFiberLeadLITActual').keyup(function (evt) {
var neValue = parseFloat($('#spnFiberLeadSpanLength').text());
var completeValue = $('#spnFiberLeadLITAccepted').text();
alert(completeValue); // show the old value not the new value inserted in textbox
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<td width="20%"><input type="text" class="text-center" id="spnFiberLeadLITActual" onkeypress="return isNumberKey(event, this)" /></td>
Here is the fiddle for the same
https://jsfiddle.net/49tvu0L8/
Please suggest what is wrong
2
Answers
use
$('#spnFiberLeadLITAccepted').val()
instead of$('#spnFiberLeadLITAccepted').text()
Lots of mistakes:
a) jQuery library missing
b) To get the input box value use
.val()
c) function
isNumberKey
code is missing.d)
onkeypress
andkeyup
are both used on the same input. You can use one of them and apply all checks over there onlyWorking snippet: