如何为OnKeyPress事件编写JavaScript,以输入文本模式属性为"MultiLine"的文本框的MaxLength; FormView EditeTemplate中的TextBox [英] how to write javascript for OnKeyPress Event to enter MaxLength of textbox whose textmode propery is "MultiLine" TextBox IN FormView EditeTemplate

查看:138
本文介绍了如何为OnKeyPress事件编写JavaScript,以输入文本模式属性为"MultiLine"的文本框的MaxLength; FormView EditeTemplate中的TextBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Fprmview控件的EditItemTemplate中有一个Textbox控件.

我将其Textmode属性设置为= Multiline
但是我想限制用户在文本框中输入超过45个字符.

I have an Textbox control in EditItemTemplate of Fprmview control.

I set Its Textmode property =Multiline
But I want restrict the user to enter more than 45 characters in textbox.

推荐答案

尝试如下所示..

在您的aspx页面中

Try like below..

In you aspx page

<textarea name="Description" id="Description"  onkeyup="CheckLength(this,''250'');">Text</textarea>



在脚本部分中



in you script section

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
function CheckLength(obj,  max) {

         if (parseInt(max) > parseInt(


(obj).val().length)) { } else { alert("Exceded max lentgh"); } }
(obj).val().length)) { } else { alert("Exceded max lentgh"); } }


这篇关于如何为OnKeyPress事件编写JavaScript,以输入文本模式属性为"MultiLine"的文本框的MaxLength; FormView EditeTemplate中的TextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆