| // 自行处理按钮 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 (strText.match(expMask)) // 移动光标 // 得到一个文本框控件的当前光标位置 |
JavaScript在ASP中实现掩码文本框
来源:ybbqy 作者: 2007-12-12 出处:pcdog.com
