The code below I am trying to test for user to enter salary but when I enter a value less than 5000 or more than 4999 it still says You do not qualify for a credit card. Why? I tried various combinations of the comparison operators >, >=, <, <= and it still just fronted out "You do not qualify for a credit card"
Please help me with this. Thanks in advance.
Code:<script type="text/javascript"> /* <=!=[=C=D=A=T=A=[ */ /* ]=]=> */ var salary = function(earnings) { if (document.getElementById(earnings) > 4999) { alert("You qualify for a credit card! Please come in."); } else if (document.getElementById(earnings) < 5000 ) { alert("You do not qualify for a credit card"); } else { alert("You did not enter anything"); } }; </script>
HTML Code:<form action=""> <p><input type="text" placeholder="Enter salary" maxlength="30" id="earnings" /></p> <p><input type="submit" value="Enter" onclick="salary(earnings)" /></p> </form>