zoukankan      html  css  js  c++  java
  • input text 文本框 字符限制

    input text中只能输入数字和"-"号
    <input type='text' onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" />

    只能输入汉字

    <input onkeyup="value=value.replace(/[^u4E00-u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^u4E00-u9FA5]/g,''))">

    只能输入全角
    <input onkeyup="value=value.replace(/[^uFF00-uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^uFF00-uFFFF]/g,''))">

    只能输入数字
    <input onkeyup="value=value.replace(/[^d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))">


    只能输入英文和数字
    <input onkeyup="value=value.replace(/[W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))">


    默认显示
    <input name="username" type="text" id="username" onFocus="this.value='';" value="用户名、手机" class="input" size="14">

  • 相关阅读:
    iOS堆栈-内存-代码在据算机中的运行
    iOS self和super的区别
    php代码优化
    缓存雪崩现象解决方案
    缓存失效
    分布式memcache
    Linux下编译安装Memcache
    windows 下安装 php-memcached 扩展
    Linux下安装 php-memcache 扩展
    缓存之文件缓存
  • 原文地址:https://www.cnblogs.com/RedRoshan/p/4048900.html
Copyright © 2011-2022 走看看