F
F
Fredd Monty2016-09-03 21:07:09
css
Fredd Monty, 2016-09-03 21:07:09

How to add an asterisk to a placeholder inside an input?

Hello!
How to insert an asterisk?
8fd79fad02f2406d9a9fba40c50f03e7.png
I found one way, but it's a bit unfinished.
When clicked, it disappears, but if left empty, it does not appear.

<div class="container">
  <div class="col-md-4">
    <form>
      <div class="form-group">
        <input type="email" type="email" class="form-control" id="exampleInputEmail1" onclick="hideIcon()" placeholder="Email Address">
      </div>
    </form>
  </div>
</div>

.form-group {
  padding: 50px 0;
  background-image: url("../img/star.png");
  background-repeat: no-repeat;	
}

function hideIcon() {
  document.getElementById('exampleInputEmail1').style.backgroundImage = 'none';
}

Who does what?
Thanks to all!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex Glebov, 2016-09-03
@ferds

I'd say it's a designer's mistake and left the asterisk greyed out.
If it doesn't work, you can do it like this https://jsfiddle.net/Lo33tnbp/

M
Maxim, 2016-09-04
@m77x

It seems to me, or does your input sin with the absence of name with the redundancy of type ?
js can be used
$('input[name=email]').val('e-mail*');

G
gwenn, 2016-09-06
@gwenn

.placeholder:after {
  position: absolute;
  top: 0;
  right: 0;
  color: red;
  content: '*';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question