2

I can't seem to find anything similar to this right now, but I am pretty sure I have seen something like it before.

I am currently able to use either input or textarea html tags and the placeholder attribute to get something close to what I want, but I also want to provide the user the ability to copy the placeholder text and enter/paste it in the same box as an entry. Is this possible?

An use case would be a place holder of a common directory path: box1@mtk:/path/to/data/20180202_TextFile.txt

I want the user to be able to copy and paste "box1@mtk:/path/to/data/" into the box so they just have to change the text file name.

I can't force value to be the placeholder because I don't want users accidentally submitting forms without modifying all fields.

So is it possible to have selectable / copyable placeholders?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Michael Kapp
  • 97
  • 3
  • 11
  • Doesn't this helps you? https://stackoverflow.com/questions/44568404/how-do-i-copy-to-clipboard-with-the-input-or-placeholder-name – Claudio Nastasi Junior Mar 15 '18 at 21:17
  • 3
    In a word, no. They would not be placeholder attributes at that point. You could use what's in the linked answer from @ClaudioNastasiJunior, but that's kind of messy. I'd just have the text in the text box, add an `input` event handler to flag that the user has touched the value, and if not, don't enable the submit button. – Heretic Monkey Mar 15 '18 at 21:21
  • 4
    Why not just make that text the default `value` of the input? – Scott Marcus Mar 15 '18 at 21:21
  • is there a certain event you want to bind to? Like a button press or focus or something? – CumminUp07 Mar 15 '18 at 21:22
  • I feel like it might be easier to have a button next to the box that says "default" – zfrisch Mar 15 '18 at 21:39
  • Agree with Marcus. Just set the input default value...you can also change its color to look like a placeholder. You can even make it disappear when user clicks on it, and provide a button if user wants to accept "placeholder" value. – Cybernetic Mar 15 '18 at 21:42

1 Answers1

0

No you have to choose between placeholder and value. I would just use value in combination with a script that enables the button when all the fields are different from their default value or prints an error message if they are not eg:

if(document.getElementById(“value1”).value !== “DEFAULT TEXT” && document.getElementById(“value2”).value !== “DEFAULT TEXT” && ......) {
    document.getElementById(“submit”).disabled = false;
}