0

is there any way to set color to a text box placeholder

<div class="row">
    <div class="col col-50">
        <input type="number" placeholder="Price Color" name="price" class="textbox" ng-model="Price"required>
    </div>    
    <div class="col col-50">
        <input type="number" placeholder="Discount Color" class="textbox" ng-model="discount">
    </div>    
</div>

i want to change the color inside the text box placeholder that is "Price Color" and "Discount Color" this string color to be red when values entered must be black

Yokesh Varadhan
  • 1,636
  • 4
  • 21
  • 47
  • 3
    possible duplicate of [Change an input's HTML5 placeholder color with CSS](http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css) – Bhojendra Rauniyar Sep 10 '15 at 08:02
  • thank you i tried it but it applies color to a single box and when i type values in that textbox it also changes to red . i have combination of textbox and combobox inside a popup – Yokesh Varadhan Sep 10 '15 at 08:07

1 Answers1

1

You can do something like:

<div class="row">
    <div class="col col-50">
        <input type="number" placeholder="Price Color" name="price" class="textbox" ng-model="Price" ng-class="{'placeholder': Price == 'Price Color'}" required>
    </div>    
    <div class="col col-50">
        <input type="number" placeholder="Discount Color" class="textbox" ng-model="discount"  ng-class="{'placeholder': discount== 'Discount Color'}">
    </div>    
</div>

And set 'placeholder' class for the color you want. Obviously put the values of 'Discount Color' and 'Price Color' in some variable

AlexD
  • 4,062
  • 5
  • 38
  • 65
  • i am new to programming i dont know about ng-class. is there any possibility only using css – Yokesh Varadhan Sep 10 '15 at 08:19
  • ngClass adds a class to the element when a condition is met, pretty straight-forward. So the 'placeholder' will be added to the input only when rice == 'Price Color' is true. Try and provide a fiddle if you need more help – AlexD Sep 10 '15 at 08:45