<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>禁止输入空格键</title> <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script> </head> <body> <input type="text" /> </body> <script> $('input').keydown(function(e) { if (e.keyCode == 32) { return false; } }); </script> </html>