我有一個基本的密碼強度指示器。如何在剃鬚刀中設置數據顯示器
<input type="password" id="myElement1" size="40" class="left" data-display="myDisplayElement1" />
<div class="left" id="myDisplayElement1"></div>
我有JS Script
照顧所有的邏輯。並且data-display div
顯示消息密碼是弱還是強。但我想將上面的代碼轉換成Razor。下面是我到現在爲止的內容。
<div class="form-group">
@Html.LabelFor(model => model.NewPassword, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NewPassword, new { htmlAttributes = new { @class = "form-control", id = "myElement1" } })
<div class="left" id="myDisplayElement1"></div>
@Html.ValidationMessageFor(model => model.NewPassword, "", new { @class = "text-danger" })
</div>
</div>
問題:一切正常,但我無法將數據顯示屬性放入剃鬚刀中。我需要把它放在哪裏。但是由於數據顯示沒有設置,我無法以div的形式顯示用戶的密碼強度。
我希望能夠做一些類似下面
@Html.EditorFor(model => model.NewPassword, new { htmlAttributes = new { @class = "form-control", id = "myElement1" , data-display = "myDisplayElement1"} })
但data-display
給我的錯誤。
錯誤
無法解析符號data
錯誤來在那裏我已經加入data-display
的地方。
請閱讀[問],分享你的研究成果,並在下次提到確切的錯誤。 – CodeCaster
我已添加錯誤消息。我也把代碼片段。如果您滿意,請拿出反對票。謝謝! – Unbreakable