0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

テキストエリアに入力された文字数をカウントしてリアルタイムに表示する

Posted at
            TableRow tr = new TableRow();
            TableCell tc = new TableCell();
            TextBox tb = new TextBox();

            tb.CssClass = "expensesid";
            tb.ID = "expensesid" + list.IndexOf(data);
            tb.Attributes.Add("onKeyUp", "ShowLength(value," + list.IndexOf(data) + "," + "200);");
            tb.Text = data.expensesid;
            tc.Controls.Add(tb);

            Label cnt = new Label();
            cnt.ID = "expensesidCnt" + list.IndexOf(data);
            cnt.Text = "入力文字数 " + data.expensesid.Length.ToString() + "/200文字";
            tc.Controls.Add(cnt);

            tr.Controls.Add(tc);

<script type="text/javascript">
    function ShowLength(str,row,maxLength) {
        document.getElementById("MainContent_expensesidCnt" + row).innerHTML = "入力文字数 " + str.length + "/" + maxLength  + "文字";
    }
</script>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?