Get input value lenght and add 3 dots after input field when input fields lenght * 8 is bigger than 360

Viewed 23

I wrote a code for adding 3 dots (...) when input field's value is too long. But It didn't work (I checked .after("...") its works)

If the number of letters times 8 is greater than 350, 3 dots must be added

var degisinput = document.querySelector(".degistirilebilirinput").value;
if(degisinput.lenght * 8 > 350)
{
  $(".bloklink .degistirilebilirinput").after("...");
}
1 Answers

Take first strings (input values are always string when u reach them) then take first 3 chars from it and add three dots while doing that they are inside of val() function .

var degisinput = document.querySelector(".degistirilebilirinput").value;
    if(degisinput.lenght * 8 > 350)
    {
      $(".bloklink .degistirilebilirinput").val(
        Number($(".bloklink .degistirilebilirinput")
        .val().slice(3))+'...'

       )
    }
Related