在HTML textarea中禁用换行符 [英] Disable linebreaks in HTML textarea
本文介绍了在HTML textarea中禁用换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用CSS或任何其他方式,是否可以禁止在HTML文本区域中的换行符?
with CSS or any other way, is it possible to disallow newlines in a HTML textarea? So basically I want nothing to happen when the user presses "enter".
推荐答案
使用jQuery,你可以这样做:
Using jQuery, you could do it like this:
$(document).ready(function() {
$("#t_area").keypress(function(event) {
if(event.which == '13') {
return false;
}
});
});
<textarea id="t_area"></textarea>
我也会使用PHP或ASP或任何服务器端脚本语言以及彻底彻底。
I would also strip out any newlines using PHP or ASP or whatever server-side scripting language you have access to as well to be completely thorough.
这篇关于在HTML textarea中禁用换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文