Advertisement
krot

validity input

Jun 21st, 2017
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.64 KB | None | 0 0
  1. <form>
  2.   <div>
  3.     <label for="balloons">Number of balloons to order (multiples of 10):</label>
  4.     <input id="balloons" type="number" name="balloons" step="10" min="0" max="100" required>
  5.     <span class="validity"></span>
  6.   </div>
  7.   <div>
  8.     <input type="submit">
  9.   </div>
  10. </form>
  11. </style>
  12. div {
  13.   margin-bottom: 10px;
  14.   position: relative;
  15. }
  16.  
  17. input[type="number"] {
  18.   width: 100px;
  19. }
  20.  
  21. input + span {
  22.   padding-right: 30px;
  23. }
  24.  
  25. input:invalid+span:after {
  26.   position: absolute;
  27.   content: '✖';
  28.   padding-left: 5px;
  29. }
  30.  
  31. input:valid+span:after {
  32.   position: absolute;
  33.   content: '✓';
  34.   padding-left: 5px;
  35. }
  36. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement