【问题标题】:How to make input text field read-only如何将输入文本字段设为只读
【发布时间】:2020-03-03 17:24:18
【问题描述】:
<div class="form-group">
 <label for="bit_app_policy_category_status">Please Insert the Code<span class="required">*</span></label>
 <input type="text" name="code" class="form-control" value="{{$category->code}}" placeholder="Enter the Code" />
</div>

我只想让该字段无法更改,但只能查看。

【问题讨论】:

  • 使用 ether 的 diabled 或 readonly 属性
  • 感谢我刚刚在后面添加了只读及其工作

标签: html laravel laravel-5


【解决方案1】:

html 对此有两个属性。 readonlydisabled。当任何输入字段具有disabled 属性时,该值将不可编辑。并且该值也不会随表单传递。在readonly 属性的情况下,值将不可编辑,但将与表单一起传递。所以使用readonly

<input type="text" name="code" class="form-control" value="{{$category->code}}" placeholder="Enter the Code" readonly />

【讨论】:

    【解决方案2】:
    <input type="text" name="code" class="form-control" value="{{$category->code}}" placeholder="Enter the Code" readonly />
    

    <input type="text" name="code" class="form-control" value="{{$category->code}}" placeholder="Enter the Code" disabled />
    

    【讨论】:

      【解决方案3】:

      像这样使用只读:-

      <input type="text" name="code" class="form-control" value="{{$category->code}}" placeholder="Enter the Code" readonly/>
      

      【讨论】:

        【解决方案4】:
        <input type="text" name="code" class="form-control" value="{{$category->code}}" placeholder="Enter the Code" disabled />`
        

        在输入中添加禁用。

        【讨论】:

          猜你喜欢
          • 2020-05-09
          • 2020-07-30
          • 1970-01-01
          • 2013-05-24
          • 2023-03-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多