How to display watermark instead of value in textbox in ASP.Net MVC?

后端 未结 2 691
一整个雨季
一整个雨季 2021-01-20 09:29

In my view I have

<%= Html.TextBoxFor(m => m.Patient.Weight, new { title = \"Weight\" , style = \"width: 3em\", @class = \"fieldRequired watermark\" }         


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-20 10:28

    (I wanted to include this as a comment but the system won't let me do that without 50 points... So I am placing it here as an "answer", even though I am focusing on terminology only.)

    Actually, the OP's use of the term "watermark" is in alignment with Microsoft's use of the term as it relates to text boxes rendered by MVC Html helper objects that generate HTML input tags. Yet it is true that HTML5 introduces the placeholder attribute for input tags of type text, search, url, tel, email, and password. The disconnect here is that the HTML5 standard refers to the "hint text" you see in HTML input boxes as the "placeholder" text while Microsoft refers to it as the "watermark".

    But Microsoft might have used the term specifically because it sometimes refers to an input tag's watermark as the image that has been specified in the style of that input object before data is entered by the user. So while Microsoft uses the term to describe the text or image that appears as a hint, the HTML5 placeholder attribute can only specify text.

提交回复
热议问题