0
votes

Below is my code snippet

<input type="tel" min="1" id="maskBarToMile" name="toMile" class="form-control inp-to quantity-input maskBarToMile" value='<s:if test="%{parameterToMile != null}" ><s:property value="%{parameterToMile}" /></s:if>' />

But it is failing in w3c validation and I am getting an error as below

Attribute min not allowed on element input at this point.

How can I use "min" attribute with "tel" input type so that it passes the w3c validation? P.S : I am new to HTML5. TIA.

1
What does "min" even mean in the context of a telephone number?! Either it's a valid telephone number or it's not, either it's empty, or it's not. A "minimum" amount of telephone number doesn't make any sense. - deceze

1 Answers

-2
votes

Use 'data-min' instead. And type = number.

https://jsfiddle.net/o72k69cj/

try it:

  <input type="number" data-min="1" id="maskBarToMile" onkeyup="validate_phone(this)">


   <script>
   function validate_phone(element)
   {
      var min = element.getAttribute('data-min');
      if (element.value.length<min)
      {console.log('value is not acceptable');}
   }
   </script>