ASP网络中的JavaScript [英] javascript in asp net

查看:54
本文介绍了ASP网络中的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我创建了一种如何计算剩下要键入的字符

JavaScript代码是

Hello all

I created a how to count the character left to type

The JavaScript code is

<script type="text/javascript" language="javascript">
    function validatelimit(obj, maxchar)
     {
        if (this.id) obj = this;
        var remaningChar = maxchar - obj.value.length;
        document.getElementById('<%= Label1.ClientID %>').innerHTML = remaningChar;
        if (remaningChar <= 0) {

            obj.focus();

            obj.value = obj.value.substring(maxchar, 0);

            alert('Character Limit exceeds!');

            return false;

        }

        else

        { return true; }

    }

</script>



在asp源文件中,



In asp source file,

<asp:TextBox ID="txt_Skill" runat="server" TextMode="MultiLine" onkeyup="validatelimit(this,50)"></asp:TextBox>



它正在工作,但是当我刷新页面时,标签包含的最大值为255.

我要如何在255个字符之后禁用书写字符.

任何人都可以帮助我



It is working but when i am refreshing the page that time the label contains the maxvalue as 255.

I want how i disable the writing character after 255 no of character.

Any body help me

推荐答案

尝试一下简单的方法

Asp.Net中多行文本框中的最大长度 [ ^ ]
Try this which is simple

Max Length in Multiline TextBox in Asp.Net[^]


您确定没有更改回发中后端的值吗?
Are you sure that you didn''t change value from backend in postback?


使用文本框的MaxLength属性....我相信将解决您的问题
Use MaxLength property of text box....I believe it will solve your problem


这篇关于ASP网络中的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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