"Required field styling with tooltip"
Bootstrap 3.1.0 Snippet by rusboard

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<form role="form" style="width:400px; margin: 0 auto;">
<h1>Contact us</h1>
<div class="required-field-block">
<input type="text" placeholder="Name" class="form-control">
<div class="required-icon">
<div class="text">*</div>
</div>
</div>
<div class="required-field-block">
<input type="text" placeholder="Email" class="form-control">
<div class="required-icon">
<div class="text">*</div>
</div>
</div>
<input type="text" placeholder="Phone" class="form-control">
<div class="required-field-block">
<textarea rows="3" class="form-control" placeholder="Message"></textarea>
<div class="required-icon">
<div class="text">*</div>
</div>
</div>
<button class="btn btn-primary">Send</button>
</form>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
input, textarea, button { margin-top:10px }
/* Required field START */
.required-field-block {
position: relative;
}
.required-field-block .required-icon {
display: inline-block;
vertical-align: middle;
margin: -0.25em 0.25em 0em;
background-color: #E8E8E8;
border-color: #E8E8E8;
padding: 0.5em 0.8em;
color: rgba(0, 0, 0, 0.65);
text-transform: uppercase;
font-weight: normal;
border-radius: 0.325em;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: background 0.1s linear;
-moz-transition: background 0.1s linear;
transition: background 0.1s linear;
font-size: 75%;
}
.required-field-block .required-icon {
background-color: transparent;
position: absolute;
top: 0em;
right: 0em;
z-index: 10;
margin: 0em;
width: 30px;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
$(function() {
$('.required-icon').tooltip({
placement: 'left',
title: 'Required field'
});
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments:

Beautiful work

Fabian Manzano () - 9 years ago - Reply 0


What about select items ( list ) ?

Sam () - 9 years ago - Reply 0


Useful snippet. When used in date control then the date control dropdown is unaccessible as the "required-field-block" sits on top of it. Is there is anyway we can do the required-field-block as left alighted so that other control specific functionality will not be disturbed.

Ravivit9 () - 10 years ago - Reply 0


really simple UI. Really like this one. Bravo

Sekai92 () - 10 years ago - Reply 0


Corner image doesn't move along with the field border as it's resized.

Mike () - 10 years ago - Reply 0


It blinks when hovered, but really good UX.

Rafael C () - 10 years ago - Reply 0


Hi, what OS and browser version?

Rusboard () - 10 years ago - Reply 0


Windows 8.1, lastest Chrome

Now, I'm in Ubuntu 14.04 Latest Firefox it runs nicely = )

Rafael C () - 10 years ago - Reply 0


hi

sara () - 9 years ago - Reply 0


test

d () - 9 years ago - Reply 0


Happens to me too. Windows 7, latest Google Chrome.

Alex () - 10 years ago - Reply 0