заполнитель ввода не отображается - PullRequest
0 голосов
/ 10 ноября 2019

заполнитель не отображается, пока я не сфокусируюсь, а затем не сфокусирую поле.

<input type="tel" name="natid" id="natid" class="form-control"    onfocus="this.placeholder = ''" onblur="this.placeholder = 'Hello'" required="" value="" maxlength="10" pattern="[0-9]{10}" style="width: 100%;height: 10vw;color: #000;font-weight: 400;font-size: 5vw;letter-spacing: 0.5em;">

Ответы [ 3 ]

1 голос
/ 10 ноября 2019

Добавьте placeholder="hello" к вашему тегу.

<input type="tel" name="natid" id="natid" class="form-control" placeholder="Hello"    onfocus="this.placeholder = ''" onblur="this.placeholder = 'Hello'" required="" value="" maxlength="10" pattern="[0-9]{10}" style="width: 100%;height: 10vw;color: #000;font-weight: 400;font-size: 5vw;letter-spacing: 0.5em;">
0 голосов
/ 10 ноября 2019

добавить еще один атрибут placeholder = "Hello". поэтому при загрузке страницы будет отображаться заполнитель.

<input type="tel" name="natid" id="natid" class="form-control" placeholder="Hello"   onfocus="this.placeholder = ''" onblur="this.placeholder='Hello'" required="" value="" maxlength="10" pattern="[0-9]{10}" style="width: 100%;height: 10vw; color: #000; font-weight: 400; font-size: 5vw;letter-spacing: 0.5em;">
0 голосов
/ 10 ноября 2019

Это потому, что вы написали деталь:

onblur="this.placeholder = 'Hello'" 

Таким образом, заполнитель будет установлен только для события размытия

Чтобы явно установить заполнитель, используйте свойство placeholder для inputтег:

<input placeholder="Hello">
...