ITPub博客

首页 > Linux操作系统 > Linux操作系统 > jQuery实现文本框只能输入数字处理

jQuery实现文本框只能输入数字处理

原创 Linux操作系统 作者:664054106 时间:2012-07-31 15:27:29 0 删除 编辑

//文本框只能是数值
    $("#DepartmentID").keyup(function() {
        var tmptxt = $(this).val();
        $(this).val(tmptxt.replace(/\D|/g, ''));
    }).bind("paste", function() {
        var tmptxt = $(this).val();
        $(this).val(tmptxt.replace(/\D|/g, ''));
    }).css("ime-mode", "disabled");

    //文本框只能是数值并且首字符不能为0
    $("#tel").keyup(function() {
        var tmptxt = $(this).val();
        $(this).val(tmptxt.replace(/\D|^0/g, ''));
    }).bind("paste", function() {
        var tmptxt = $(this).val();
        $(this).val(tmptxt.replace(/\D|^0/g, ''));
    }).css("ime-mode", "disabled");

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26481450/viewspace-739211/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-11-25

  • 博文量
    27
  • 访问量
    78455