Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. JavaScript
  2.  
  3. <input type="text" numberonly="true" /> // 숫자만 입력 가능한 텍스트박스
  4. <input type="text" datetimeonly="true" /> // 숫자, 콜론(:), 하이픈(-)만 입력 가능한 텍스트박스
  5.  
  6. $(function(){
  7. $(document).on("keyup", "input:text[numberOnly]", function() {$(this).val( $(this).val().replace(/[^0-9]/gi,"") );});
  8. $(document).on("keyup", "input:text[datetimeOnly]", function() {$(this).val( $(this).val().replace(/[^0-9:\-]/gi,"") );});
  9. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement