-1

I have this input which I need to set to readonly using jquery. Below is what I've done so far, but the code is not working. What is my mistake here?

HTML:

<input type="text" placeholder="" data-field-id="field26" name="field26[]" data-min-char="" data-max-char="" data-val-type="url" data-regexp="" data-is-required="false" data-allow-spaces="" class="validation-lenient" data-placement="right" data-toggle="tooltip" tooltip="" data-trigger="focus" data-html="true" data-input-mask="" data-mask-placeholder="">

js:

$( document ).ready(function() {
    input('[data-field-id="field26"]').setAttribute("readonly", true);
    $('[data-field-id="field26"]').setAttribute("readonly", true);
});
freedomn-m
  • 27,664
  • 8
  • 35
  • 57
JPashs
  • 13,044
  • 10
  • 42
  • 65

2 Answers2

0
$(document).ready(function() {
    $('[data-field-id="field26"]').attr("readonly", true);
});
Nidhin Chandran
  • 846
  • 8
  • 19
0

try

$("#fieldName").prop("readonly", true);

or add atributed disabled="disabled"

Rahul
  • 1
  • 1