Replace on Focus (form)

/ Published in: HTML
Save to your folder(s)

This just replaces the default value of a form element. Then it bring it back if you click away.

Copy this code and paste it in your HTML
  1. <input type="text" value="Your Name" name="name" onblur="if (this.value == '') {this.value = 'Your Name';}" onfocus="if (this.value == 'Your Name') {this.value = '';}" />
  2. </form>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.