I can easily create a html input field that has text already in it. But when the user clicks on the input field the text doesn't disappears but stays there. The user then has to manually remove the text to type. How can I create an input field where when the user clicks on the input field box the text then disappear?
See-through souls. Going, going, gone. You can also make an element so transparent that it's invisible using the opacity CSS property. Like visibility: hidden, opacity: 0.0 will leave an empty space where the HTML element is.
The <input type="hidden"> defines a hidden input field. A hidden field let web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.
blur(function () { if(this. value == ''){ this. value = 'ENTER VALUE'; } }); //this will empty the field is the value is the default one $("#valueText").
What you want to do is use the HTML5 attribute placeholder
which lets you set a default value for your input box:
<input type="text" name="inputBox" placeholder="enter your text here">
This should achieve what you're looking for. However, be careful because the placeholder attribute is not supported in Internet Explorer 9 and earlier versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With