怎么控制文本框只能输入货币格式的字符串?实在没分了,,唉。。

TaoTaoYou 2005-10-31 05:58:31
先谢了啊,,
...全文
103 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
八哥 2005-11-01
  • 打赏
  • 举报
回复
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
#dv{
width:100;
height:15;
overflow-x:hidden;
overflow-y:hidden;
}
</style>
<table width=500 border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#000000" style="word-break:break-all; " id="Test">
<tr height="20" bgcolor=#ffffff><td width=100 >不限制</td><td width=100>小写转大写</td><td width=100 >大写转小写</td><td width=100 >只能为正整数</td><td width=100>负数和小数</td></tr>
<tr height="20" bgcolor=#ffffff><td ><div id="dv" contentEditable=true></td><td ><div id="dv" contentEditable=true><td ><div id="dv" contentEditable=true></td><td ><div id="dv" contentEditable=true></td><td><div id="dv" contentEditable=true></td></tr>
</table>

<script language="vbScript">
Private sub Test_onkeypress()
Dim thisObject,KeyAscii
Set thisObject = Window.event.srcElement
If thisObject.parentElement.tagName<>"TD" Then Exit Sub
KeyAscii=window.event.keyCode
Select Case thisObject.parentElement.cellIndex
Case 1
CheckKeyCode KeyAscii,thisObject.innerText,1,0,0
Case 2
CheckKeyCode KeyAscii,thisObject.innerText,2,0,0
Case 3
CheckKeyCode KeyAscii,thisObject.innerText,0,0,0
Case 4
CheckKeyCode KeyAscii,thisObject.innerText,0,1,1
End select
End Sub

'=========================================================================================================
Public Sub CheckKeyCode(KeyAscii,objCode,UppeLower,Minus,Point)
'UppeLower 为0不管,为1小写转大写,为2大写转小写
'文本框只能输入数字 Minus 是否允许-负号输入,Pointl是否允许小数点输入
If UppeLower= 1 Then
If KeyAscii >96 And KeyAscii<123 Then
KeyAscii=KeyAscii-32
End If
ElseIf UppeLower= 2 Then
If KeyAscii >64 And KeyAscii<91 Then
KeyAscii=KeyAscii+32
End If
ElseIf KeyAscii<58 And KeyAscii>44 And KeyAscii<>47 Then
If Minus And KeyAscii=45 And objCode="" Then
'无变化,可以输入负号
ElseIf KeyAscii=8 Then
'无变化,退格键不屏蔽
ElseIf KeyAscii=46 And Point And InStr(objCode, ".")=0 Then
'无变化,可以输入小数
ElseIf KeyAscii> 47 And KeyAscii< 58 THEN
Else
KeyAscii=0
End IF
ELSE
KeyAscii=0
End If
window.event.keyCode=KeyAscii
End Sub

</SCRIPT>
TaoTaoYou 2005-11-01
  • 打赏
  • 举报
回复
??没分就真的没人帮吗

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧