jquery - Validate the length of an input be exactly 10 in a form with html5 -


i have form (bootstrap v.3.0) , want check length of input 10. want use html5 solution used pattern=".{10,10}" doesn't work... here bootply

<form class="form-horizontal" role="form">   <div class="form-group">         <label for="id9" class="col-sm-2 control-label">phone</label>         <div class="col-sm-5">         <input type="number" name="j_phone" id="id9" pattern=".{10,10}" class="form-control" placeholder="phone number" required>         </div>   </div>    <div class="form-group">     <div class="col-sm-offset-2 col-sm-10">       <button type="submit" class="btn btn-default">ok</button>     </div>   </div>  </form> 

you can't use type="number" , pattern attribute together. instead change type text , modify pattern allow numbers.

<input type="text" pattern="[0-9]{10}"> 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -