I use this code in my login panel in MVC3:
@Html.PasswordFor( m => m.Password, new { maxlength = 10 } )
I want to do that, somebody cannot to PASTE any password to PasswordFor
.
(To enter password ONLY with typing)
what must i do?
I use this code in my login panel in MVC3:
@Html.PasswordFor( m => m.Password, new { maxlength = 10 } )
I want to do that, somebody cannot to PASTE any password to PasswordFor
.
(To enter password ONLY with typing)
what must i do?
You probably shouldn't do as it completely sucks from user's perspective but if you want your users to hate you, you could do this:
$('#Password').bind('paste', function(e) {
e.preventDefault();
});
Something like:
var pw = document.getElementById("Password");
pw.addEventListener("paste", function(event)
{
event.preventDefault();
}
... with equivalent event listening and default prevention for IE etc.
jQuery:
$("#Password").bind("paste", function(event)
{
event.preventDefault();
});
Neither will work on Opera.
But then, you shouldn't be doing it in any event. My personal way of "pasting" passwords is way more secure than you tampering with my browser's default user experience. And you're messing with my method, which is likely to make me pick a less secure password specifically for your site. Or not use it.
You can use like this
$(document).ready(function(){
$('#Password').live("paste",function(e) {
e.preventDefault();
});
});