开发者

Undefined null or an object error in javascript

I am mvc 2.0 for that in a particular textbox have set the maximun charcter for the textbox...but seems to get undefined error this is my view

  <td>
          <%= Html.TextArea("Description", Model.Description, new{id = "descriptionId",onKeyDown = "limitText(this.开发者_开发知识库form.Description,this.form.countdown,1000);",onKeyUp = "limitText(this.form.Description,this.form.countdown,1000);"})%>
                            </td>

This is my script....

  function limitText(limitField, limitCount, limitNum) {
        if (limitField.value.length > limitNum) {
            limitField.value = limitField.value.substring(0, limitNum);
        } else {
            limitCount.value = limitNum - limitField.value.length;
            alert(limitCount.value);
        }
    }


Looks like you might have ASP.NET control IDs confused with JavaScript IDs. Look in the HTML source output for the ID value on that description text box and use that where you currently have this.form.Description. It will probably end up as this.form.DescriptionId or this.form.DescriptionId_ctl0 or some other ridiculous ID that ASP.NET decides to generate for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜