Not allow a blank character/space in a input form

use*_*123 2 javascript forms character

Is it possible to not allow a blank character/space in a input form like below?

<input type="text" value="" maxlength="30" name="email" class="formfield w0">
Run Code Online (Sandbox Code Playgroud)

Rai*_*ica 10

检查这个小提琴.相关代码:

$(function() {
    $('#input1').on('keypress', function(e) {
        if (e.which == 32)
            return false;
    });
});
Run Code Online (Sandbox Code Playgroud)

  • 如果用户复制并粘贴输入,则不起作用。 (3认同)