【发布时间】:2018-05-07 22:49:40
【问题描述】:
我想限制下面的空文本框和文本区域框中的空间 代码在移动设备中无法运行,它在桌面上运行,请检查并提供帮助
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("input[type=text],textarea").keypress(function(e) {
if(e.which === 32 && !this.value.length) {
return e.which !== 32;
}
});
});
</script>
</head>
<input type="text" maxlength='25'>
<textarea></textarea>
</html>
【问题讨论】:
标签: javascript jquery html css