How to disable space key on a password field

jquery, keyup

Solution

If you really need live behaviour.

$(document).on('keydown', '#passwordId', function(e) {
    if (e.keyCode == 32) return false;
});

Problem

How to disable space key on a password field.I've tried ``` $(document).ready(function() { $("#passwordId").live('keyup',function(e){ if (e.keyCode == 32) { // e.preventDefault(); return false; } }); }); ``` I even tried e.preventDefault();.On debugging it does enter in if but does not disable space key.Don't know what I am doing wrong.

Original source