Skip to content

Clear Input Field Value When Selected

  1. function clearDefault(el) {
  2.   if (el.defaultValue==el.value) el.value = “”
  3. }
  4. // Then call this function using the ‘onfocus’ value of your input box:
  5. <input value=“Your Comment” onfocus=“clearDefault(this)” type=“text”>