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