hi,欢迎访问本站!
当前位置: 首页学习笔记正文

input禁止输入

用户投稿 学习笔记 16阅读

input标签禁止输入的方法:

  添加   οnfοcus="this.blur()"  使元素失去焦点    将属性   maxlength  的值设为 0  

例如:<input type="number" name="" id="" max="10" min="1" οnfοcus="this.blur()">

例如:<input type="text" maxlength="0">

input标签禁用的方法:

  添加   disabled    禁用属性    添加   readonly    只读属性  

注意:“禁用” 和 “禁止输入” 是有区别的,禁用会使input自带的功能丧失,标签呈灰色状态。而禁止输入仍能保持原有功能

 

 注意:下方是源代码,可直接复制

<form action="">

    <input type="text" placeholder="输入用户名" value="" maxlength="4">

    <input type="password" name="" id=""maxlength="6">

    <br>

    <input type="radio" name="chgo" id="">yes

    <input type="radio" name="chgo" id="">no

    <br>

    <input type="checkbox" name="cheeses" id="">one

    <input type="checkbox" name="cheeses" id="">two

    <input type="checkbox" name="cheeses" id="">three

    <input type="file" name="" id="" multiple>

    <input type="submit" value="register">

    <input type="reset" value="reset">

    <input type="button" value="button">

    <button>button</button>

    <input type="number" name="" id="" max="10" min="1" οnfοcus="this.blur()">

    <input type="range" max="20" min="0" value="20">

    <input type="color" name="" id="">

    <input type="date">

    <br>

    <input type="checkbox" name="" id="kikout">

    <label for="kikout">打钩</label>

    <select multiple>

      <option value="">one</option>

      <option value="">two</option>

      <option value="">three</option>

    </select>

    <textarea style="resize: none;"></textarea>

  </form>

标签:
声明:无特别说明,转载请标明本文来源!
发布评论
正文 取消