1

My Function:

 function Get() {
        debugger
        var za = document.getElementById(contnm + 'hdcap').value;
       var nums = document.getElementById(contnm + 'TxtQUANTITY').value;
       if (nums > za)
       {
            alert('Quantity should be less than Capacity.');
            document.getElementById(contnm + 'TxtQUANTITY').value = '';      
        }
    }

My hdcap value is 100000, means za = 100000. & TxtQUANTITY value is 3000, means nums = 3000.

if i take TxtQUANTITY = 1000 then its working properly but if i take TxtQUANTITY = 2000 or 3000 or 5000 or 4000 or 20000 or 30000 then it showing alert.

NOTE:

if i put directly values like if (3000 > 100000) then its working but in js with variable its not working.

  • What **type** do you think those two variables are? – mjwills Sep 26 '18 at 09:54
  • Possible duplicate of [How do I convert a string into an integer in JavaScript?](https://stackoverflow.com/questions/1133770/how-do-i-convert-a-string-into-an-integer-in-javascript) – mjwills Sep 26 '18 at 09:54

1 Answers1

1

value are of type string. Try converting the value to number:

if (Number(nums) > Number(za))
Mamun
  • 66,969
  • 9
  • 47
  • 59