Hide Form Input Text onClick

Here’s a simple little tutorial on how to hide form input text “onClick” using Javascript.

Notice you’ll need to include these elements within the input field: onclick, onblur, and value.

<div class="wp-block-codemirror-blocks code-block alignfull">
<pre class="CodeMirror" data-setting="{"mode":"htmlmixed","mime":"text/html","theme":"material","lineNumbers":true,"lineWrapping":true,"styleActiveLine":true,"readOnly":true,"align":"full"}"><input type="text" name="name" onclick="if(this.value=='Enter your name'){this.value=''}" onblur="if(this.value==''){this.value='Enter your name'}" value="Enter your name" /></pre>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.