2

i am using django python, i apply placeholder for my forms fields in forms.py ,like

self.fields['email'].widget.attrs['class']            = 'form-text'
self.fields['country'].widget.attrs['class']          = 'form-dropdownfield'
self.fields['email'].widget.attrs['placeholder']            = 'Email*'
in .css file
.form-text
{
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    height: 30px;
    width: 300px;
    border-radius:8px;
    border:none;
    box-shadow:-1px 1px 1px 0 rgba(0, 0, 0, 0.1) inset;
    border:1px solid #D2D2D2;
    padding-left:10px;
}

Question 1: Place holder working properly in all browser but not in IE,what can i do for IE problem? Question 2: Country field is dropdown list,how can apply placeholder for this one?

okm
  • 23,575
  • 5
  • 83
  • 90
ganga
  • 21
  • 1
  • 3

2 Answers2

3

Placeholders work for INPUT form elements, but not for SELECT (dropdown) elements. This question has a number of answers that offer strategies for default values of dropdown elements.

Though I'm not sure, it's possible that many versions of IE don't support the placeholder attribute (and this post suggests that they're unsupported).
If placeholder is unsupported in a version of IE that you want to support, you could try a polyfill such as https://github.com/ginader/HTML5-placeholder-polyfill

Community
  • 1
  • 1
Geoffrey Hing
  • 1,575
  • 2
  • 15
  • 22
-1

No need to take any javscript or any method you can just do it with your html css

HTML

<select id="myAwesomeSelect">
    <option selected="selected" class="s">Country Name</option>
    <option value="1">Option #1</option>
    <option value="2">Option #2</option>

</select>

Css

.s
{
    color:white;
        font-size:0px;
    display:none;
}