I have done a bit of hunting on the web, and have yet to find any concrete answer to this. Is it possible to have a text field, with default text in it that is non editable?
For example, say I need a user to input a phone number. What they see is:
Input Phone Number: ***-***-****
They can edit any of the stars they want. However, even if the field were completely empty, there should be no way that the dashes could be removed.
I've seen the readonly
and disabled
tags for the input area, but those render the entire field disabled.
I want the user to be able to input information, without changing the characters I've set default into the input field.
Here's some dummy code if you need it to experiment with:
<!doctype HTML>
<html>
<body>
<section>
<article>
<label>Phone Number Entry: </label>
<input type="tel" name="phone" placeholder="123-456-7890"
onkeypress='eval(event)' required/>
</article>
</section>
</body>
</html>