2

How do i Make a part of Text Not Editable ..

My .html code is

 <input type="text" placeholder="Enter Company Name" class="wc-form-control nobg" formControlName="subject" " id="subjectid">

My .ts code is to append the Input box with class

var el = document.createElement("span");
        el.innerHTML = ('<span class="nonEdit"> {{' + this.checboxvalue + '}} </span>');
        this.editecompanydetail.patchValue({subject: this.editecompanydetail.value.subject + el.innerHTML })

But it is getting appended with tag , Any solution on this ...

2 Answers2

0

You could try to add contenteditable="false" like this:

var el = document.createElement("span");
        el.innerHTML = ('<span class="nonEdit" contenteditable="false"> {{' + this.checboxvalue + '}} </span>');
        this.editecompanydetail.patchValue({subject: this.editecompanydetail.value.subject + el.innerHTML })

You could also try with readonly:

var el = document.createElement("span");
        el.innerHTML = ('<span class="nonEdit" readonly> {{' + this.checboxvalue + '}} </span>');
        this.editecompanydetail.patchValue({subject: this.editecompanydetail.value.subject + el.innerHTML })

hope it helps :)

Similar cases:

More on the topic:

reymon359
  • 1,240
  • 2
  • 11
  • 34
0

Try adding [disabled] = true to make the field non editable to your input tag.

Venkatesh K
  • 133
  • 1
  • 1
  • 11