The javascript operators in my program could not identify integers that ends with all zeros. For example it can’t identify 10, 100, 2000, 90000 etc. Which also means any number with trailing 0’s can’t be read. It could identify and compare 20001 and such.
Sample code:
if ((document.forms.frmApprovalTrainees.elements[TxtFldName].value) > 100 )
{
alert("Please enter approved quantity less than the requested");
return false;
}
The (document.forms.frmApprovalTrainees.elements[TxtFldName].value) is supposed to retrieve the input value for validation. In the case above the operator identifies the 100 as 1. Any idea how to solve this?
Because an input’s value is a string. Use
parseInt(). Don’t forget to use a decimal radix.The radix is there to make sure the string is parsed as a decimal number (and not octal or hexadecimal, as
FFFFcan be though of as a number as well).