gpt4 book ai didi

css - 50个字符时文本框自动换行asp.net

转载 作者:太空宇宙 更新时间:2023-11-04 11:29:35 24 4
gpt4 key购买 nike

我有一个供用户输入的文本框,下面的代码是我如何创建文本框的。

<asp:TextBox ID="txtIncidentDesc" runat="server" Height="50px" Width="441px" Columns="4" Rows="8"></asp:TextBox>

我想当用户输入长文本时,比如

tttttttttttttttttttttttttttttttttttttttttttttttttttttttttt

每当它遇到 50 个字符时,它会自动换行

tttttttttttttttttttttttt

tttttttttttttttttttttttt

有人知道我的代码有什么问题吗?

提前致谢!

非常感谢您的意见和建议!

最佳答案

试试这个例子。它会为您提供线索并帮助您找到解决方案。

    var cnt = 1;
function newline(text) {
var val = document.getElementById(text).value;

var t;
if (cnt > 1)
t = (val.length / 10 * 10) / cnt;
else
t = val.length;

if (t == 10) {
document.getElementById(text).value = val + '\n';
cnt = cnt + 1;
}
}
<textarea id="tb" onkeypress="newline(this.id)" cols="30" rows="4"></textarea>

关于css - 50个字符时文本框自动换行asp.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32109284/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com