一.下载插件
  http://digitalbush.com/projects/masked-input-plugin/
二。属性
a: 表示只能输入大小写字母
9:表示只能输入0-9之间的数字
*:a和9的结合
placeholder:占位符
三。方法
mask(param1,pararm2):param1:限制输入格式,param2:制定占位符
umask():删除输入格式的限制
四.扩展 方法 
可以根据自己的需求限制输入格式例如:
$.mask.definitions['z']='[123]';表示只能输入123数字
五.例子 
<!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>
    <title></title>

    <script type="text/javascript" src="http://zhyj0303.blog.163.com/blog/../../js/jquery-1.4.2.js"></script>

    <script type="text/javascript" src="http://zhyj0303.blog.163.com/blog/../../js/jquery.maskedinput-1.2.2.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
        $("#txtdate").mask("99/99/9999", { placeholder: "|" });
            $("#txtphone").mask("(999) 999-9999");
            $("#txttin").mask("99-9999999");
            $("#txtmax").mask("999/99/9999");
            $("#txtdemo1").mask("**/***/****");
            $("#txtdemo2").mask("aa/aaa/aaa");
            
            //自定义格式
            $.mask.definitions['z'] = '[123]';//Z:表示只能输入123
            $("#txtdemo3").mask("zz/ zzz/ zzzz");
        });
       
    </script>

</head>
<body>
    <input type="text" >自定义的输入方式(zz/zzz/zzz)</span><br />
</body>
</html>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2021-11-09
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2021-12-14
  • 2021-11-30
相关资源
相似解决方案