以下のようなJqueryを使用するとうまくいきます。
テキストボックス
<input class="user-reg-input fl" type="text" name="Percentage[]" id="Percentage1" value="" onpaste="return false"
onkeypress="if(event.keyCode<48 || event.keyCode>57)event.returnValue=false;" maxlength="6" />
Jクエリ
$(document).ready(function ()
{
$('#Percentage1').keyup(function (event)
{
var currentValue = $(this).val();
var length = currentValue.length;
if (length == 2)
{
$(this).val(currentValue + ".");
}
else if (length == 5)
{
$(this).val(currentValue + "%");
}
});
});
これは基本的な要件に対して機能しますが、改善が必要な点がいくつかあります。ユーザーが複数の番号を削除しようとした場合、機能しないか、バックスペース キーを使用しようとした場合