首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

JavaScript在ASP中实现掩码文本框

整理日期:2007年08月05日 【字体:


伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-08/1186287640.html
然后处理相应需要处理的键盘消息。
这里随便处理几个必要的就可以了,因为文本框本身也不需要什么太多的用户操作,所以把光标的前移、后移、删除操作进行处理,这样你的文本框就有了基本的操作,现在操作起来已经很顺手了。
// 自行处理按钮
switch (nKeyCode)
{
case 8:// 如果动作是退格[<-]
{
strText = strText.substr(0,nCursorPos-1) + strText.substr(nCursorPos, nTextLen-nCursorPos);
nCursorPos--;
break;
}
case 46:// 如果动作是del[del]
{
strText = strText.substr(0,nCursorPos) + strText.substr(nCursorPos+1,nTextLen-nCursorPos-1);
nCursorPos--;
break;
}
case 38:// 如果动作是方向键[上]
case 39:// 如果动作是方向键[右]
{
nCursorPos++;
break;
}

case 37:// 如果动作是方向键[左]
case 40:// 如果动作是方向键[下]
{
nCursorPos--;
break;
}
default :
{
strText = strText.substr(0,nCursorPos) + String.fromCharCode(nKeyCode) + strText.substr(nCursorPos,nTextLen);

nCursorPos++;
if (nCursorPos>strText.length)
Tags:
JavaScript在ASP中实现掩码文本框
'http://www.etoow.com/html/2007-08/1186287640.html
1
 
23
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved