How to change the color of HTML input value?

In the input field (text) I have text that disappears after clicking it. How can I make this text easier by editing its color?

Sorry, the code looks dirty, I had to cut it to show you.

Thank!

James

<form>
   <input type="text" name="search" size="35"    
    onclick="this.value='';"onfocus="this.select()"
    onblur="this.value=!this.value?'Job Title   
    e.g. Assistant Manager':this.value;"
    value="Job Title e.g. Assistant Manager" 
    style="background-color:white; border: 
    solid 1px #6E6E6E; height: 30px; font-size:18px; 
    vertical-align:9px"/>

   <input type="text" name="searchterm" size="35" 
    style="background-color:white; border: solid 1px #6E6E6E;
    height: 30px; font-size:18px; vertical-align:9px"/>

   <input type="image" src="but.tiff" alt="Submit" width="60">
</form>
+5
source share
4 answers

Maybe something like this (just add your own style):

<input type="text" 
       size="35" 
       value="Job Title e.g. Assistant Manager" 
       style="background-color:white; 
              border: solid 1px #6E6E6E;
              height: 30px; 
              font-size:18px; 
              vertical-align:9px;color:#bbb" 
        onfocus="if(this.value == 'Job Title e.g. Assistant Manager') {
                    this.value = '';
                    this.style.color='#000';
                 }" />

<input type="text" 
       name="searchterm" size="35" 
       style="background-color:white; 
              border: solid 1px #6E6E6E;
              height: 30px; 
              font-size:18px; 
              vertical-align:9px" />
+10
source

You can add color to your input style rule: color:#ccc;

+5
source

CSS color JavaScript onclick ( , value):

<input type="text" onclick="this.value=''; this.style.color='#000'" />

, JavaScript. ID JavaScript <script> :

document.getElementById("yourInput").onclick = function() {
    this.value = '';
    this.style.color = '#000';
}
+3
source

Please try the following:

<input class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-8 col-md-offset-2" type="text" name="name" value="" placeholder="Your Name" style="background-color:blue;"/>

Basically you put all the CSS in the style of the input tag, and it works.

0
source

All Articles