1、问题背景
在一个输入框中,限制字符串长度为12位,利用键盘输入一个数字,会将字符串中最后一位替换,比如:111111111111,再输入一个3,会显示111111111113
2、具体实现
<!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=utf-8" />
<title>JavaScript替换字符串中最后一个字符</title>
<script type="text/javascript">
function replaceStr()
{
var e = event || window.event || arguments.callee.caller.arguments[0];
var input_str = document.