I'm doing a simple number comparison on the keyUp event of an input field. For some reason, I'm not getting the expected result, and I can't figure out why. What should happen is that if the user-entered number is larger than that stored in the html attribute, the background should turn red, otherwise it stays white. Simply entering '9' will turn the background red. ??
var admin = $('input[name="diskStorage"]').attr('data-adminstorage'); // 2097152000
$('#new-user input[name="diskStorage"]').keyup(function(){
if(admin < $(this).val())
$(this).css('background','red');
else
$(this).css('background','white');
});
When I debug these values, if(2097152000 < 549) is returning true. Here's the html, in case that makes any difference:
<form action="administrate.php" method="post" id="new-user">
<table><tbody><tr>
...
</tr><tr>
<td>Disk Storage Limit:</td>
<td>
<input type="text" data-adminStorage="2097152000" name="diskStorage" value="" /> megaBytes<br />
<span id="info"></span></td>
...
</tr></tbody></table>
Here it is live: http://jsfiddle.net/JMC_Creative/dqAJj/2/