My code looks like
<div class="col-4">@Html.LabelFor(m => m.Password)</div>
<div class="col-8">
@Html.EditorFor(m => m.Password)
@Html.ValidationMessageFor(m => m.Password)
</div>
I am using Javascript in my application.
How to write onfoucsout/onblue event to my Password textbox?
You can try like below:
<div class="col-8">
@Html.EditorFor(m => m.Password, new { htmlAttributes = new { onblur = "OnBlurEvent()" } })
@Html.ValidationMessageFor(m => m.Password)
</div>
@section scripts{
<script type="text/javascript">
function OnBlurEvent() {
alert("Hello!");
}
</script>
}
Or use Anonymous Function
@section scripts{
<script type="text/javascript">
$('#Password').blur(function(){
alert("Hello!");
});
</script>
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.