Using "min" attribute with input type "tel" - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Number

Description

Using "min" attribute with input type "tel"

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <input type="number" data-min="1" id="maskBarToMile" onkeyup="validate_phone(this)"> 
      <script>
   function validate_phone(element)
   {//from w ww  . j  a v a  2 s  .  co  m
      var min = element.getAttribute('data-min');
      if (element.value.length<min)
      {console.log('value is not acceptable');}
   }
   
      </script>  
   </body>
</html>

Related Tutorials