如何使用Html帮助器在mvc中显示密码隐藏字段 [英] how to show the password hidden field in mvc using Html helper

查看:300
本文介绍了如何使用Html帮助器在mvc中显示密码隐藏字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@Html.Password("pasword", null, new { @class = "form-control frmField", placeholder = "Password" })

我正在使用这个,我希望这里应该是我点击的一个按钮,密码变得可见。我知道这将通过jquery或Javascript,但我无法理解在mvc中。如何在mvc中应用该技术?

I am using this and I want that here should be one button which I click and the the password becomes visible. I know this will be through jquery or Javascript, but I am not able to understand that in mvc. How to apply that technique in mvc?

<input data-toggle="password" type="password"  data-placement="after" data-eye-class="glyphicon" data-eye-open-class="glyphicon glyphicon-eye-open" data-eye-close-class="glyphicon glyphicon-eye-close" data-eye-class-position="true" class="form-control pwd">
<input type="text" class="form-control" placeholder="password" style="display:none;" /> 

我用过这个并且效果很好。如何在mvc中实现这个?

I have used this and it worked good. How to implement this in mvc?

推荐答案

密码类型更改为文字 type

change Password type to text type

$( ".btnShow" ).mousedown(function() {
  $(".pwd").attr("type","text");
});
$( ".btnShow" ).on("mouseleave",function() {
  $(".pwd").attr("type","password");
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input  type="password"  class="form-control pwd">
<input type="button" class="btnShow" value="show"/>

这篇关于如何使用Html帮助器在mvc中显示密码隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆