jquery validator no space

JavaScript
        $('#IdElement').keypress(function (e) {
            if (e.which === 32)
                return false;
        })

Source

Also in JavaScript: