zoukankan
html css js c++ java
js代码小记(判断textbox的长度,并且固定最多收入字符)
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=gb2312"
/>
<
title
>
Untitled Document
</
title
>
<
SCRIPT
language
=javascript1.3
>
<!--
var
testleng
=
300
;
//
允许多少字符串填入
function
GC_UpdateCharCount()
{
var
desc_el
=
document.getElementById('desc');
var
remainingchars_el
=
document.getElementById('remainingchars');
var
num_remaining
=
testleng
-
desc_el.value.length;
if
(num_remaining
>=
0
)
{
remainingchars_el.innerHTML
=
num_remaining;
}
else
{
remainingchars_el.innerHTML
=
"
<font color=red>
"
+
(
-
num_remaining
+
'')
+
"
characters over</font>
"
;
}
}
function
isOver(sText)
{
var
intlen
=
sText.value.length;
if
(intlen
>
testleng)
{
alert(
"
描述特征的内容的字数必修小于或者等于
"
+
testleng);
sText.focus();
sText.select();
}
}
//
--></SCRIPT>
</
head
>
<
body
>
<<
B
>
Group description
</
B
><
BR
><
TEXTAREA id
=
desc onkeydown
=
GC_UpdateCharCount() onkeyup
=
GC_UpdateCharCount() onblur
=
"
isOver(this);
"
style
=
"
WIDTH: 99%
"
name
=
desc rows
=
4
cols
=
50
></
TEXTAREA
>
<
BR
>
Letters remaining:
<
SPAN id
=
remainingchars
>
<
SCRIPT language
=
javascript1.
2
><!--
GC_UpdateCharCount();
//
--></SCRIPT></SPAN><NOSCRIPT>300 characters allowed </NOSCRIPT>
</
body
>
</
html
>
效果参考:
www.lostfound.cn/CoutChar.html
查看全文
相关阅读:
变焦与对焦的区别
教你在Zuul中增加Filter过滤请求
FEIGN开启对HYSTRIX支持
Feign使用Hystrix
Spring Boot中使用Redis小结
Spring 中的事件机制 ApplicationEventPublisher
SpringBoot+EasyExcel实现Excel的导出
SpringBoot–集成验证码kaptcha实现验证码功能
Spring Cloud使用Feign调用服务接口
Spring cloud ReadTimeout 问题解决
原文地址:https://www.cnblogs.com/xucanzhao/p/420594.html
最新文章
【sprinb-boot】@ComponentScan 跳过扫描 excludeFilters
R 统计 NA 的数量
R 统计True/ False的数目
featureCounts 安装和使用
关于libstdc++.so.6: version `GLIBCXX_3.4.20' not found 问题解决
The following requested languages could not be built: gfortran
HISAT2 下载和使用
GitHub:深度学习最全资料集锦
CVPR 2021
深度学习机器学习顶会
热门文章
Contrastive Learning(CL,对比学习)
Qt 状态机 事件迁移
Qt状态机框架——如何避免状态爆炸
Qt状态机 QStateMachine
状态机设计模式 浅析
qt 状态机框架初探
模拟信号和数字信号
模拟相机及数字相机应用区别分析
摄像机分类(2)
监控摄像机的分类
Copyright © 2011-2022 走看看