Skip to content Skip to sidebar Skip to footer

Change Css Style Html5 Form Required Attribute Required Message

i work with RTLbootstrap for RTL project. now i have any form with HTML5 form required attribute required message. in action i have this ballon for input: I need To change Like Th

Solution 1:

Chrome does not allow styling form validation bubbles anymore:

See Details

Firefox has no way to style the error bubbles

See Details

Solution 2:

hey i found a link here and they have used this trick.They have appended a class to the input type. and displayed message there .Hope that helps after little customization. working codepen: http://codepen.io/smarty_tech/pen/ONZRVp

<formid="frm"action="action"><div><label>Email</label><inputtype="email"required="required"/><spanclass="theTooltip">Invalid email</span></div><div><buttonformnovalidate="formnovalidate">OK</button></div>

document.querySelector('#frm').addEventListener('submit',e=> {
   e.preventDefault();e.currentTarget.classList.add('submitted');
 });bodyfont-family:Helvetica,sans-serifdisplay:flexflex-direction:columnalign-items:centerjustify-content:centeroverflow:hiddenwidth:100%height:100vhbackgroundorangeform>divposition:relativemargin-bottom:10px.theTooltip$bgcolor=rgba(black,0.7)$arrow=10$radius=5$maxWidth=250$padding=15backface-visibility:hiddenwill-change:opacity,visibilitymax-width:$maxWidth*1pxborder-radius:$radius*1pxbackground-color:$bgcolorpadding:$padding*1pxcolor:whitebox-sizing:border-boxdisplay:inline-blockposition:absolutetransform-style:preserve-3dtransform:translate(15%,-50%)top:50%;left:autoright:autobottom:autovisibility:hiddenmargin:0opacity:0transition:opacity0.3sease-outz-index:100&:aftercontent:''position:absolutewidth:0height:0top:50%margin-top:$arrow*-1pxleft:$arrow*-1pxborder-top:$arrow*1pxsolidtransparentborder-bottom:$arrow*1pxsolidtransparentborder-right:$arrow*1pxsolid$bgcolorlabeldisplay:inline-blockvertical-align:centerinputbackground:whiteborder:1pxsolidtransparentcursor:pointerdisplay:inline-blockoverflow:visiblemargin:0outline:0vertical-align:centertext-decoration:nonewidth:autoborder-radius:3pxcursor:textpadding:7px&:focus&:activeoutline:none.submittedinput&:invalidborder:1pxsolidred~.theTooltipvisibility:visibleopacity:1&:valid~.theTooltiptransition:opacity0.3s,visibility0s0.3s

Solution 3:

Example of Message with only css3

Code :

.tooltip, .arrow:after {
  background: black;
  border: 2px solid white;
}

.tooltip {
  pointer-events: none;
  opacity: 0;
  display: inline-block;
  position: absolute;
  padding: 10px20px;
  color: white;
  border-radius: 20px;
  margin-top: 20px;
  text-align: center;
  font: bold 14px"Helvetica Neue", Sans-Serif;
  font-stretch: condensed;
  text-decoration: none;
  text-transform: uppercase;
  box-shadow: 007px black;
}
.arrow {
  width: 70px;
  height: 16px;
  overflow: hidden;
  position: absolute;
  left: 50%;
  margin-left: -35px;
  bottom: -16px;
}
.arrow:after {
   content: "";
   position: absolute;
   left: 20px;
   top: -20px;
   width: 25px;
   height: 25px;
   -webkit-box-shadow: 6px5px9px -9px black,5px6px9px -9px black;
   -moz-box-shadow: 6px5px9px -9px black,5px6px9px -9px black;
   box-shadow: 6px5px9px -9px black,5px6px9px -9px black;
  -webkit-transform: rotate(45deg);
  -moz-transform:    rotate(45deg);
  -ms-transform:     rotate(45deg);
  -o-transform:      rotate(45deg); 
}
.tooltip.active {
  opacity: 1;
  margin-top: 5px;
  -webkit-transition: all 0.2s ease;
  -moz-transition:    all 0.2s ease;
  -ms-transition:     all 0.2s ease;
  -o-transition:      all 0.2s ease;
}
.tooltip.out {
  opacity: 0;
  margin-top: -20px;
}

Post a Comment for "Change Css Style Html5 Form Required Attribute Required Message"