I am trying to compare the values of two input fields with jQuery. However, it does seem correct but it doesn\'t alert when one of the values is larger.
alert
<
You're comparing strings, not integers. You can use parseInt() to convert them. Try this:
parseInt()
if (parseInt($('#charsLeft').val(), 10) < parseInt($('#charsLeft2').val(), 10)) { alert('Key is shorter than the plaintext'); }
Updated fiddle