惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
T
Threatpost
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园 - Franky
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
M
MIT News - Artificial intelligence
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
S
Security Affairs
P
Proofpoint News Feed
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
S
Security @ Cisco Blogs
H
Hacker News: Front Page
Security Archives - TechRepublic
Security Archives - TechRepublic
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
Know Your Adversary
Know Your Adversary
Y
Y Combinator Blog
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
月光博客
月光博客
量子位
博客园_首页
The Last Watchdog
The Last Watchdog
D
DataBreaches.Net
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed
The Register - Security
The Register - Security
Schneier on Security
Schneier on Security
H
Help Net Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
V
Visual Studio Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure
C
Cyber Attacks, Cyber Crime and Cyber Security
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
S
Schneier on Security
L
Lohrmann on Cybersecurity
S
Secure Thoughts
Stack Overflow Blog
Stack Overflow Blog
Cloudbric
Cloudbric
Microsoft Security Blog
Microsoft Security Blog

博客园 - 嚣张的沉默

读写txt文档 限制TextBox输入字数 我常用的正则与SQL语句 DataSet导入到Excel 年月日联动的JS代码 用户控件的传值方法 Repeater模板列 asp.net的几个小技巧 百叶窗效果 建站安全 倒计时代码 解决SQL2000安装服务器挂起 删除.NET的最近项目 屏幕右下角弹出广告 DataSet写入、导出XML 上传图片重命名并创建文件夹 自动跳转页面带参数 微软出的AJAX控件的安装(转载) 第一次开博
计算TextBox输入的字数
嚣张的沉默 · 2008-03-05 · via 博客园 - 嚣张的沉默

<script language="javascript" type="text/javascript" >
    
// change()方法 在id 为txt 的TextBox 触发 onkeyup 事件时执行
        function change()
        
{
            
//找到txt 并获得他的内容
            var value=document.getElementById('txt').value;
            
//计算还可以输入多少字符
            var sum=20-value.length;
            
//判断能输入的字符数是否为负
            if(sum<0)
            
{
                
//找到显示控件 并显示相应提示
                document.getElementById('showDiv').innerHTML= '您还可以输入'+sum+'字符';
                
//为负设置颜色为红色
                document.getElementById('showDiv').style.color='red';
            }

            
else
                document.getElementById(
'showDiv').innerHTML= '您还可以输入'+sum+'字符';
        }

        
</script>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
    
<asp:TextBox ID='txt' runat="server" onkeyup="change()"  ></asp:TextBox>
        
<div id='showDiv'>您还可以输入20字符</div>
        

    
</div>

posted on 2008-03-05 16:07  嚣张的沉默  阅读(440)  评论(0)    收藏  举报

刷新页面返回顶部