最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to change default input tooltip text that shows in required input - Stack Overflow

programmeradmin2浏览0评论

There is a tooltip when my mouse is over the textbox : "please fill out this field" is there a way too change this text ?

if you hover on this field you can see the massage :

<input type="text" name="yourname" required/>

There is a tooltip when my mouse is over the textbox : "please fill out this field" is there a way too change this text ?

if you hover on this field you can see the massage :

<input type="text" name="yourname" required/>

Share Improve this question asked Feb 12, 2020 at 15:14 inazinaz 1,7855 gold badges22 silver badges43 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

This could be easily done using the title HTML attribute.

title Attribute

The title attribute belongs to the Global Attribute. It allows to specify extra information about an element. This information is shown as a tooptip text when the mouse moves over the element.

<input type="text" name="yourname" required title="You changed it !!"/>


If its something related to the text showed after validation. For that you could use the function setCustomValidity along with an event Handler . Here we would use the event Handler oninvalid.

Your code could be written as :

<input type="text" name="yourname" required oninvalid="this.setCustomValidity('Yo! You changed it')" oniput="this.setCustomValidity('Yo! You changed it')" title="test"/>

you can add a title on your input

<input title="test" type="text" name="yourname" required/>

发布评论

评论列表(0)

  1. 暂无评论