Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"only text /only number - text field"
Bootstrap 3.3.0 Snippet by
Kiraan
3.3.0
Preview
HTML
CSS
JS
View Full Screen
Fork
Fork this
60.8K
 
91 Fav
Post to Facebook
Tweet this
<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; }
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76