skip to Main Content
Menu

Dynamic Input Color

Ever had the need to highlight your <input>’s by coloring the border and/or placing initial values with initial colors? Well here is a very simple way of doing it in just one line..

<input style=”color: #f00″ type=”text” value=”Your email” onblur=”if(this.value == ”) { this.style.color=’#f00′; this.value=’Your email’}” onfocus=”if (this.value == ‘Your email’) {this.style.color=’#0f0′; this.value=”}”>

Source : http://www.nicolaskuttler.com/post/html-forms-and-onclick-onfocus/

Alphonse

Editorial Staff at ETN Multimedia is led by Alphonse Tan. Page maintained by Alphonse Tan

Back To Top