复制和粘贴时,MVC Razor字段标签重叠

时间:2019-07-17 00:28:44

标签: razor mvcrazor

<div class="labelled-text-field">
     @Html.LabelFor(x => x.Email)
     @Html.TextBoxFor(x => x.Email)
     @Html.ValidationMessageFor(x => x.Email)
</div>

enter image description here

使用右键单击时->粘贴标签与粘贴的电子邮件重叠:

enter image description here

键入或使用Ctrl + v(粘贴)时效果很好:

enter image description here

我不知道使用剃刀oncopy事件是否可以解决此问题:

@Html.TextBoxFor(x => x.Email, 
              new { 
                    @class = "input_box", 
                    id = "txtDays", 
                    onpaste="" 
                  }
               ) 

1 个答案:

答案 0 :(得分:0)

尝试使用占位符属性。粘贴文本时,它将清除水印。

<div class="labelled-text-field">
    @Html.LabelFor(x => x.Email)
    @Html.TextBoxFor(x => x.Email, new {placeholder="Your Email" })
    @Html.ValidationMessageFor(x => x.Email)
</div>