I have a text box with an id of EmpNum. I cannot figure out how to use jQuery's isNumeric to check to see if the value is numeric or not.
I tried:
('#.EmpNum').IsNumeric
but that did not work.
I have a text box with an id of EmpNum. I cannot figure out how to use jQuery's isNumeric to check to see if the value is numeric or not.
I tried:
('#.EmpNum').IsNumeric
but that did not work.
according to http://api.jquery.com/jQuery.isNumeric/
it's :jQuery.isNumeric(value)
so, it should be $.isNumeric($("#EmpNum").val())
Shouldn't it be more like...
if($.isNumeric($('#EmpNum').val()))
Depending on what version of jQuery you are using, but as "$.isNumeric()" function is deprecated (https://jquery.com/upgrade-guide/3.0/#breaking-change-jquery-isnumeric-and-custom-tostring) since jQuery Core 3.0 Update, I found a custom solution for this problem (originally posted here: https://stackoverflow.com/a/9716488/3323790):
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
Try the following:
$.isNumeric($('#EmpNum').text())
Also the isNumeric method was only added in version 1.7, which version are you using?