0
我已经使用下面的代码来限制字符,但它不工作..请帮助我。提前致谢。如何限制jQuery标签输入中的字符?
<td nowrap="nowrap">
<asp:TextBox MaxLength="60" runat="server" ID="Keyword" CssClass="TaskTitle" Width="270px"
TextMode="SingleLine" />
</td>
$('#Keyword_tag').bind('keyup', function() {
var characterLimit = 60;
var charactersUsed = $('#Keyword').val();
charactersUsed = charactersUsed.replaceAll(',');
if (charactersUsed.length > characterLimit) {
alert(charactersUsed.length);
charactersUsed.length = characterLimit;
alert(charactersUsed.length);
$(this).val($(this).val().slice(0, characterLimit));
$(this).scrollTop($(this)[0].scrollHeight);
}
我必须将字符限制为60,但是当我将字符限制值赋给使用的字符时,它不会被赋值。我使用jQuery的标签输入插件为关键字字段
你可以给最大长度属性到您正在使用的输入标签。 – Jai
@jaiPsah Maxlength属性不起作用.. – Ramesh