JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<label class="zakaz-txt">Телефон:</label> <input required="required" class="zakaz-inpt" type="tel" pattern="8[0-9]{3}-[0-9]{3}-[0-9]{2}-[0-9]{2}" name="phone_zakaz" />
<span class="form_hint">Пример: 8937-999-99-99</span>
</div>
CSS
.zakaz-inpt {
width:60%; height:28px; margin-left: 80px; padding-left: 5px;
}
.zakaz-txtarea {width:60%; max-width: 60%; height:100px; max-height: 200px; border:1px solid #ccc; margin-left: 80px; padding-left: 5px; padding-top: 5px;}
/* form element visual styles */
.zakaz-inpt, .zakaz-txtarea {
border:1px solid #aaa;
box-shadow: 0px 0px 3px #ccc, 0 2px 10px #eee inset;
border-radius:2px;
margin-bottom: 35px;
}
.zakaz-inpt:focus, .zakaz-txtarea:focus {
background: #fff;
border:1px solid #555;
box-shadow: 0 0 3px #aaa;
-moz-transition: box-shadow .25s;
-webkit-transition: box-shadow .25s;
-o-transition: box-shadow .25s;
transition: box-shadow .25s;
}
/* === HTML5 validation styles === */
.zakaz-inpt:required {
background: #fff url(../images/red_asterisk.png) no-repeat 98% center;
}
.zakaz-inpt:required:valid, .zakaz-txtarea:required:valid {
background: #fff url(../images/valid.png) no-repeat 98% center;
box-shadow: 0 0 5px #5cd053;
border-color: #28921f;
}
.zakaz-inpt:focus:invalid, .zakaz-txtarea:focus:invalid {
background: #fff url(../images/invalid.png) no-repeat 98% center;
box-shadow: 0 0 5px #d45252;
border-color: #b03535;
}
/* === Form hints === */
.form_hint {
background: #d45252;
border-radius: 3px 3px 3px 3px;
color: white;
margin-left:8px;
margin-right: 4px;
padding: 4px 6px;
z-index: 999; /* hints stay above all other elements */
position: absolute; /* allows proper formatting if hint is two lines */
display: none;
}
.form_hint::before {
content: "\25C0";
color:#d45252;
position: absolute;
top:1px;
left:-6px;
}
.zakaz-inpt:focus + .form_hint {display: inline;}
.zakaz-inpt:required:valid + .form_hint {background: #28921f;}
.zakaz-inpt:required:valid + .form_hint::before {color:#28921f;}
.zakaz-txtarea:focus + .form_hint {display: inline;}
.zakaz-txtarea:valid + .form_hint {background: #28921f;}
.zakaz-txtarea:valid + .form_hint::before {color:#28921f;}
.required_notification...