1

In my rails application I have a form where I am showing password field and on jquery ajax success callback I am updating the value inside the password field.

Example :

$("#some-field").val('password-value');

After doing this, field is updated with the password and I see masked password in the password field.

Now My Requirement is I need to copy this masked password value and have to use it in some other browser window and need to paste in some other website's password field.

So I am searching for a good way to achieve this.

Till now I got many jquery plugins which are masking the value for normal input text field using mask(), but the problem I am facing is copying of masked value and mainly value should get copied properly when used in some other places.

Can any one has any idea on this..

Thanks you in advance

Dean

Dinesh M
  • 103
  • 2
  • 9

1 Answers1

0

You can put in an invisible input, in localStorage, in a javascript variable encoded send to server with ajax and decode there. than do what you want with it. I hope I understood well what you asked.

I think This is what You want:

function copyToClipboard (text) {
window.prompt ("Copy to clipboard: Ctrl+C, Enter", text);
}

function displayResult()
{
var x=document.getElementById("password").value;

copyToClipboard(x);
}

displayResult();;
  • Sorry I didn't understood your answer..Basically in simple terms what I want is to copy masked password/ OR any masked value with clear text in my clipboard. So that when I paste somewhere else it should properly paste proper value – Dinesh M Aug 06 '13 at 10:42
  • Thanks for the answer but this every time gives popup and in another forum I got following solution from some developer: you make a div or input containing the "hidden" text with opacity 0.001, focus() it and set it's selection on the whole content (which should be the text you want the person to copy) via javascript and somehow inform the user to press Ctrl+C to copy the data (possibly with an javascript popup-like event that stays there for a few seconds for the user to read it). But finding it difficult to make hidden field value selected/overlap with main input field to get text selec – Dinesh M Aug 07 '13 at 05:21
  • Here is the reference : reference : http://stackoverflow.com/questions/12866468/mask-text-but-still-allow-users-to-copy-it – Dinesh M Aug 07 '13 at 05:22