set password as a variable while typing
Trying to avoid any browser's stuff about autocomplete
, password suggestion
etc.
And at the same time keep the show/hide letters
functionality.
The idea is to keep password
as a variable, regardless of show/hide
state.
In the code below problem is if user press Backspace
or Delete
key. In that case the whole concept crushes down.
Any help?
var pass = "";
$('#inpass').on('input', function(){
if(!$('#checka').is(':checked')){
let a = $(this).val();
let b = a.substr(-1);
pass += b;
let c = a.replace(/.$/, '*');
$(this).val(c);
console.log(pass);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
javascript jquery html
|
show 12 more comments
Trying to avoid any browser's stuff about autocomplete
, password suggestion
etc.
And at the same time keep the show/hide letters
functionality.
The idea is to keep password
as a variable, regardless of show/hide
state.
In the code below problem is if user press Backspace
or Delete
key. In that case the whole concept crushes down.
Any help?
var pass = "";
$('#inpass').on('input', function(){
if(!$('#checka').is(':checked')){
let a = $(this).val();
let b = a.substr(-1);
pass += b;
let c = a.replace(/.$/, '*');
$(this).val(c);
console.log(pass);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
javascript jquery html
Why don't you just prevent pasting?
– iagowp
Nov 28 '18 at 18:02
3
The whole concept also fails if the user uses arrow keys to change a previous character, not just the last one.
– Taplar
Nov 28 '18 at 18:03
2
didn't get your point why don't you just use type="password"
– Sameer
Nov 28 '18 at 18:10
1
So you've tried the answers and seen that they no longer work?
– Taplar
Nov 28 '18 at 18:12
1
If it works, it is a real solution. As your question currently stands it is too broad. As have been mentioned in the comments, there are multiple issues with your code.
– Taplar
Nov 28 '18 at 18:27
|
show 12 more comments
Trying to avoid any browser's stuff about autocomplete
, password suggestion
etc.
And at the same time keep the show/hide letters
functionality.
The idea is to keep password
as a variable, regardless of show/hide
state.
In the code below problem is if user press Backspace
or Delete
key. In that case the whole concept crushes down.
Any help?
var pass = "";
$('#inpass').on('input', function(){
if(!$('#checka').is(':checked')){
let a = $(this).val();
let b = a.substr(-1);
pass += b;
let c = a.replace(/.$/, '*');
$(this).val(c);
console.log(pass);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
javascript jquery html
Trying to avoid any browser's stuff about autocomplete
, password suggestion
etc.
And at the same time keep the show/hide letters
functionality.
The idea is to keep password
as a variable, regardless of show/hide
state.
In the code below problem is if user press Backspace
or Delete
key. In that case the whole concept crushes down.
Any help?
var pass = "";
$('#inpass').on('input', function(){
if(!$('#checka').is(':checked')){
let a = $(this).val();
let b = a.substr(-1);
pass += b;
let c = a.replace(/.$/, '*');
$(this).val(c);
console.log(pass);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
var pass = "";
$('#inpass').on('input', function(){
if(!$('#checka').is(':checked')){
let a = $(this).val();
let b = a.substr(-1);
pass += b;
let c = a.replace(/.$/, '*');
$(this).val(c);
console.log(pass);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
var pass = "";
$('#inpass').on('input', function(){
if(!$('#checka').is(':checked')){
let a = $(this).val();
let b = a.substr(-1);
pass += b;
let c = a.replace(/.$/, '*');
$(this).val(c);
console.log(pass);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
javascript jquery html
javascript jquery html
asked Nov 28 '18 at 17:58
user7461846
Why don't you just prevent pasting?
– iagowp
Nov 28 '18 at 18:02
3
The whole concept also fails if the user uses arrow keys to change a previous character, not just the last one.
– Taplar
Nov 28 '18 at 18:03
2
didn't get your point why don't you just use type="password"
– Sameer
Nov 28 '18 at 18:10
1
So you've tried the answers and seen that they no longer work?
– Taplar
Nov 28 '18 at 18:12
1
If it works, it is a real solution. As your question currently stands it is too broad. As have been mentioned in the comments, there are multiple issues with your code.
– Taplar
Nov 28 '18 at 18:27
|
show 12 more comments
Why don't you just prevent pasting?
– iagowp
Nov 28 '18 at 18:02
3
The whole concept also fails if the user uses arrow keys to change a previous character, not just the last one.
– Taplar
Nov 28 '18 at 18:03
2
didn't get your point why don't you just use type="password"
– Sameer
Nov 28 '18 at 18:10
1
So you've tried the answers and seen that they no longer work?
– Taplar
Nov 28 '18 at 18:12
1
If it works, it is a real solution. As your question currently stands it is too broad. As have been mentioned in the comments, there are multiple issues with your code.
– Taplar
Nov 28 '18 at 18:27
Why don't you just prevent pasting?
– iagowp
Nov 28 '18 at 18:02
Why don't you just prevent pasting?
– iagowp
Nov 28 '18 at 18:02
3
3
The whole concept also fails if the user uses arrow keys to change a previous character, not just the last one.
– Taplar
Nov 28 '18 at 18:03
The whole concept also fails if the user uses arrow keys to change a previous character, not just the last one.
– Taplar
Nov 28 '18 at 18:03
2
2
didn't get your point why don't you just use type="password"
– Sameer
Nov 28 '18 at 18:10
didn't get your point why don't you just use type="password"
– Sameer
Nov 28 '18 at 18:10
1
1
So you've tried the answers and seen that they no longer work?
– Taplar
Nov 28 '18 at 18:12
So you've tried the answers and seen that they no longer work?
– Taplar
Nov 28 '18 at 18:12
1
1
If it works, it is a real solution. As your question currently stands it is too broad. As have been mentioned in the comments, there are multiple issues with your code.
– Taplar
Nov 28 '18 at 18:27
If it works, it is a real solution. As your question currently stands it is too broad. As have been mentioned in the comments, there are multiple issues with your code.
– Taplar
Nov 28 '18 at 18:27
|
show 12 more comments
1 Answer
1
active
oldest
votes
Added checks if it is delete or add
var pass = "";
String.prototype.replaceAt = function (index, replacement) {
return this.substr(0, index) + replacement + this.substr(index + replacement.length);
}
function setCaretPosition(ctrl, pos) {
if (ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos, pos);
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
$('#inpass').on('input', function(){
var el = document.getElementById('inpass');
let caretStart = el.selectionStart;
let a = $(this).val();
var deleteLength = pass.length - a.length;
var addLength = deleteLength * -1;
let b = a.substr(caretStart - addLength, addLength);
if (deleteLength > 0) {
pass = pass.substr(0, caretStart) + pass.substr(caretStart + deleteLength, pass.length - 1);
} else {
if (caretStart < a.length) {
pass = pass.substr(0, caretStart - addLength) + b + pass.substr(caretStart - addLength);
} else {
pass += b;
}
}
if (!$('#checka').is(':checked')) {
if (a != "" && addLength > 0) {
let c = a.replaceAt(caretStart - addLength, '*'.repeat(addLength));
$(this).val(c);
}
}
setCaretPosition(el, caretStart);
console.log(pass);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
Does strange things when ticking the 'show letters' checkbox and when using cursor keys
– freedomn-m
Nov 28 '18 at 19:10
@Amstel, almost perfectly, do you have any solution for the case infreedomn's
notice?
– user7461846
Nov 28 '18 at 19:18
@puerto I have updated the code to address freedom-m comments
– Amstel D'Almeida
Nov 29 '18 at 1:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53525445%2fset-password-as-a-variable-while-typing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Added checks if it is delete or add
var pass = "";
String.prototype.replaceAt = function (index, replacement) {
return this.substr(0, index) + replacement + this.substr(index + replacement.length);
}
function setCaretPosition(ctrl, pos) {
if (ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos, pos);
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
$('#inpass').on('input', function(){
var el = document.getElementById('inpass');
let caretStart = el.selectionStart;
let a = $(this).val();
var deleteLength = pass.length - a.length;
var addLength = deleteLength * -1;
let b = a.substr(caretStart - addLength, addLength);
if (deleteLength > 0) {
pass = pass.substr(0, caretStart) + pass.substr(caretStart + deleteLength, pass.length - 1);
} else {
if (caretStart < a.length) {
pass = pass.substr(0, caretStart - addLength) + b + pass.substr(caretStart - addLength);
} else {
pass += b;
}
}
if (!$('#checka').is(':checked')) {
if (a != "" && addLength > 0) {
let c = a.replaceAt(caretStart - addLength, '*'.repeat(addLength));
$(this).val(c);
}
}
setCaretPosition(el, caretStart);
console.log(pass);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
Does strange things when ticking the 'show letters' checkbox and when using cursor keys
– freedomn-m
Nov 28 '18 at 19:10
@Amstel, almost perfectly, do you have any solution for the case infreedomn's
notice?
– user7461846
Nov 28 '18 at 19:18
@puerto I have updated the code to address freedom-m comments
– Amstel D'Almeida
Nov 29 '18 at 1:41
add a comment |
Added checks if it is delete or add
var pass = "";
String.prototype.replaceAt = function (index, replacement) {
return this.substr(0, index) + replacement + this.substr(index + replacement.length);
}
function setCaretPosition(ctrl, pos) {
if (ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos, pos);
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
$('#inpass').on('input', function(){
var el = document.getElementById('inpass');
let caretStart = el.selectionStart;
let a = $(this).val();
var deleteLength = pass.length - a.length;
var addLength = deleteLength * -1;
let b = a.substr(caretStart - addLength, addLength);
if (deleteLength > 0) {
pass = pass.substr(0, caretStart) + pass.substr(caretStart + deleteLength, pass.length - 1);
} else {
if (caretStart < a.length) {
pass = pass.substr(0, caretStart - addLength) + b + pass.substr(caretStart - addLength);
} else {
pass += b;
}
}
if (!$('#checka').is(':checked')) {
if (a != "" && addLength > 0) {
let c = a.replaceAt(caretStart - addLength, '*'.repeat(addLength));
$(this).val(c);
}
}
setCaretPosition(el, caretStart);
console.log(pass);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
Does strange things when ticking the 'show letters' checkbox and when using cursor keys
– freedomn-m
Nov 28 '18 at 19:10
@Amstel, almost perfectly, do you have any solution for the case infreedomn's
notice?
– user7461846
Nov 28 '18 at 19:18
@puerto I have updated the code to address freedom-m comments
– Amstel D'Almeida
Nov 29 '18 at 1:41
add a comment |
Added checks if it is delete or add
var pass = "";
String.prototype.replaceAt = function (index, replacement) {
return this.substr(0, index) + replacement + this.substr(index + replacement.length);
}
function setCaretPosition(ctrl, pos) {
if (ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos, pos);
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
$('#inpass').on('input', function(){
var el = document.getElementById('inpass');
let caretStart = el.selectionStart;
let a = $(this).val();
var deleteLength = pass.length - a.length;
var addLength = deleteLength * -1;
let b = a.substr(caretStart - addLength, addLength);
if (deleteLength > 0) {
pass = pass.substr(0, caretStart) + pass.substr(caretStart + deleteLength, pass.length - 1);
} else {
if (caretStart < a.length) {
pass = pass.substr(0, caretStart - addLength) + b + pass.substr(caretStart - addLength);
} else {
pass += b;
}
}
if (!$('#checka').is(':checked')) {
if (a != "" && addLength > 0) {
let c = a.replaceAt(caretStart - addLength, '*'.repeat(addLength));
$(this).val(c);
}
}
setCaretPosition(el, caretStart);
console.log(pass);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
Added checks if it is delete or add
var pass = "";
String.prototype.replaceAt = function (index, replacement) {
return this.substr(0, index) + replacement + this.substr(index + replacement.length);
}
function setCaretPosition(ctrl, pos) {
if (ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos, pos);
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
$('#inpass').on('input', function(){
var el = document.getElementById('inpass');
let caretStart = el.selectionStart;
let a = $(this).val();
var deleteLength = pass.length - a.length;
var addLength = deleteLength * -1;
let b = a.substr(caretStart - addLength, addLength);
if (deleteLength > 0) {
pass = pass.substr(0, caretStart) + pass.substr(caretStart + deleteLength, pass.length - 1);
} else {
if (caretStart < a.length) {
pass = pass.substr(0, caretStart - addLength) + b + pass.substr(caretStart - addLength);
} else {
pass += b;
}
}
if (!$('#checka').is(':checked')) {
if (a != "" && addLength > 0) {
let c = a.replaceAt(caretStart - addLength, '*'.repeat(addLength));
$(this).val(c);
}
}
setCaretPosition(el, caretStart);
console.log(pass);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
var pass = "";
String.prototype.replaceAt = function (index, replacement) {
return this.substr(0, index) + replacement + this.substr(index + replacement.length);
}
function setCaretPosition(ctrl, pos) {
if (ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos, pos);
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
$('#inpass').on('input', function(){
var el = document.getElementById('inpass');
let caretStart = el.selectionStart;
let a = $(this).val();
var deleteLength = pass.length - a.length;
var addLength = deleteLength * -1;
let b = a.substr(caretStart - addLength, addLength);
if (deleteLength > 0) {
pass = pass.substr(0, caretStart) + pass.substr(caretStart + deleteLength, pass.length - 1);
} else {
if (caretStart < a.length) {
pass = pass.substr(0, caretStart - addLength) + b + pass.substr(caretStart - addLength);
} else {
pass += b;
}
}
if (!$('#checka').is(':checked')) {
if (a != "" && addLength > 0) {
let c = a.replaceAt(caretStart - addLength, '*'.repeat(addLength));
$(this).val(c);
}
}
setCaretPosition(el, caretStart);
console.log(pass);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
var pass = "";
String.prototype.replaceAt = function (index, replacement) {
return this.substr(0, index) + replacement + this.substr(index + replacement.length);
}
function setCaretPosition(ctrl, pos) {
if (ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos, pos);
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
$('#inpass').on('input', function(){
var el = document.getElementById('inpass');
let caretStart = el.selectionStart;
let a = $(this).val();
var deleteLength = pass.length - a.length;
var addLength = deleteLength * -1;
let b = a.substr(caretStart - addLength, addLength);
if (deleteLength > 0) {
pass = pass.substr(0, caretStart) + pass.substr(caretStart + deleteLength, pass.length - 1);
} else {
if (caretStart < a.length) {
pass = pass.substr(0, caretStart - addLength) + b + pass.substr(caretStart - addLength);
} else {
pass += b;
}
}
if (!$('#checka').is(':checked')) {
if (a != "" && addLength > 0) {
let c = a.replaceAt(caretStart - addLength, '*'.repeat(addLength));
$(this).val(c);
}
}
setCaretPosition(el, caretStart);
console.log(pass);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' id='inpass' maxlength='25' placeholder='password' title='password' autocomplete='off'>
<br><br>
<input type='checkbox' id='checka'>
<label for='checka' id='labela'>show letters</label>
edited Nov 29 '18 at 5:16
answered Nov 28 '18 at 18:36
Amstel D'AlmeidaAmstel D'Almeida
23017
23017
Does strange things when ticking the 'show letters' checkbox and when using cursor keys
– freedomn-m
Nov 28 '18 at 19:10
@Amstel, almost perfectly, do you have any solution for the case infreedomn's
notice?
– user7461846
Nov 28 '18 at 19:18
@puerto I have updated the code to address freedom-m comments
– Amstel D'Almeida
Nov 29 '18 at 1:41
add a comment |
Does strange things when ticking the 'show letters' checkbox and when using cursor keys
– freedomn-m
Nov 28 '18 at 19:10
@Amstel, almost perfectly, do you have any solution for the case infreedomn's
notice?
– user7461846
Nov 28 '18 at 19:18
@puerto I have updated the code to address freedom-m comments
– Amstel D'Almeida
Nov 29 '18 at 1:41
Does strange things when ticking the 'show letters' checkbox and when using cursor keys
– freedomn-m
Nov 28 '18 at 19:10
Does strange things when ticking the 'show letters' checkbox and when using cursor keys
– freedomn-m
Nov 28 '18 at 19:10
@Amstel, almost perfectly, do you have any solution for the case in
freedomn's
notice?– user7461846
Nov 28 '18 at 19:18
@Amstel, almost perfectly, do you have any solution for the case in
freedomn's
notice?– user7461846
Nov 28 '18 at 19:18
@puerto I have updated the code to address freedom-m comments
– Amstel D'Almeida
Nov 29 '18 at 1:41
@puerto I have updated the code to address freedom-m comments
– Amstel D'Almeida
Nov 29 '18 at 1:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53525445%2fset-password-as-a-variable-while-typing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why don't you just prevent pasting?
– iagowp
Nov 28 '18 at 18:02
3
The whole concept also fails if the user uses arrow keys to change a previous character, not just the last one.
– Taplar
Nov 28 '18 at 18:03
2
didn't get your point why don't you just use type="password"
– Sameer
Nov 28 '18 at 18:10
1
So you've tried the answers and seen that they no longer work?
– Taplar
Nov 28 '18 at 18:12
1
If it works, it is a real solution. As your question currently stands it is too broad. As have been mentioned in the comments, there are multiple issues with your code.
– Taplar
Nov 28 '18 at 18:27