[英]Struts2 textfield display length
I would like to make Struts2 textfield can display only 10 words but accept 20 words. 我想让Struts2文本字段只显示10个单词但可以接受20个单词。 See sample;
见样本;
Want to display 想要展示
1234567890
Want to accept 想要接受
12345678901234567890
If I enter 如果我进入
1234567890123
And also want to display in textfield is 1234567890.Please share me some ideas and links 而且想在textfield中显示的是1234567890.Please分享一些想法和链接
You can create your struts 2 text field which will accept max 20 character like below. 您可以创建struts 2文本字段,该字段将接受最多20个字符,如下所示。
var value = "12345678912345678912";
$('#my').val(value.substr(0,10));
for dispaly only 10 digit you need to use javascript or jquery like below code. 对于显示只有10位数你需要使用javascript或jquery如下面的代码。
var value = "12345678912345678912"; $('#my').val(value.substr(0,10));
if value is not an String then you can use. 如果value不是String,那么你可以使用。
var value = 12345678912345678912; $('#my').val(value.toString().substr(0,10));
Using this code you can achieve it 使用此代码即可实现
<s:textfield name="fieldname" value="12345678901234567890" size="10"/>
the display area of the field not exceed a 10 characters. 字段的显示区域不超过10个字符。 However, the filed can contain more than 10 characters.
但是,该字段可以包含超过10个字符。
使用固定大小,例如:
<input type="text" value="12345678901234567890" style="width:50px" />
例如:输入类型=“文本”值=“12345678901234567890”style =“width:50px”maxlength =“20”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.