"only text /only number - text field"
Bootstrap 3.3.0 Snippet by Kiraan

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="col-md-12 pd-10"> <h3>Java Script Number Only area </h3> <div class="col-md-2"><h4>Type only Number</h4> </div> <div class="col-md-4"><INPUT id="txtNumber" placeholder="XXX - XXX - XXXX" onkeypress="return isNumberKey(event)" type="text" name="txtNumber"> </div> </div> <div class="col-md-12 pd-10"> <h3>Java Script Only Text area </h3> <div class="col-md-2"><h4>Type only Text </h4> </div> <div class="col-md-4"><INPUT id="txtCharacter" onkeypress="return isNumericKey(event)" type="text" name="txtCharacter"> </div> </div> <div class="col-md-12 pd-10"> <h3>Java Script only 4 number's/character's </h3> <div class="col-md-2"><h4>Only 4 number :</h4> </div> <div class="col-md-4"> <INPUT id="txtNumber" placeholder="4 character only" onkeypress="return isNumberKey(event)" type="text" name="txtNumber" maxlength="4"> </div> </div> </div> </div>
.pd-10{ padding:20px; }
function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } function isNumericKey(evt) { var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) return true; return false; }

Related: See More


Questions / Comments: