$blocked-savedPasswordandSpesifik-Character
by mtambulut
JavaScript
/*
https://stackoverflow.com/questions/32369/disable-browser-save-password-functionality
<input asp-for="Password" type="@(ViewBag.isMobile == true ? "number" : "password")" maxlength="6" minlength="6"
class="@(ViewBag.isMobile == true ? "text-security" : "form-control")"
placeholder="@Localizer["Password"]" autocomplete="off" name="password"
onkeypress="return event.keyCode >= 48 && event.keyCode < 58">
*/
var isFocus = false;
$('#form').on('submit', function () {
$("#form #Username").val($("#visibleForm #Username").val());
$("#form #Password").val($("#visibleForm #Password").val());
});
$(".Lbutton").on("click", function () {
$("#form").trigger('submit');
})
$("#visibleForm #Username,#visibleForm #Password").keydown(function (e) {
if (e.keyCode == 13) {
$("#form").submit();
$("#form").trigger('submit');
$("button[type='submit']").trigger('click');
}
});
$("#visibleForm #Password").keydown(function (e) {
if (e.shiftKey)
return false;
if (!e.ctrlKey) {
console.log(e + "----")
$('#form').attr('autocomplete', 'off');
e.preventDefault();
e.stopPropagation();
e.target.setAttribute('readonly', true);
setTimeout(() => {
e.target.focus();
e.target.removeAttribute('readonly');
if (((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) && $(this).val().length < 6)
$("#Password").val($(this).val() + e.key)
else if (e.keyCode == 8) {
if (isFocus) {
$("#Password").val('')
isFocus = false;
} else
$("#Password").val($(this).val().substring(0, $(this).val().length - 1))
}
});
} else {
if (e.keyCode == 65 || e.keyCode == 97)
isFocus = true;
}
});