jQuery | input 박스의 class 명으로 숫자 또는 숫자+dot 만 입력 받기
페이지 정보
작성자 100K5 작성일14-06-11 13:18 조회61,042회 댓글0건관련링크
본문
$(function(){
//숫자키만 입력
$(":input").filter(".only_number").keypress(function(event){
if (event.which && (event.which < 48 || event.which > 57)) {
event.preventDefault();
}
}) .css("imeMode", "disabled");
//숫자키만 입력
$(":input").filter(".only_number").keypress(function(event){
if (event.which && (event.which < 48 || event.which > 57)) {
event.preventDefault();
}
}) .css("imeMode", "disabled");
// 또는
$('.only_number').css('imeMode','disabled').keypress(function(event) {
if(event.which && (event.which < 48 || event.which > 57) ) {
event.preventDefault();
}
}).keyup(function() {
if( $(this).val() != null && $(this).val() != '' ) {
$(this).val( $(this).val().replace(/[^0-9]/g, '') );
}
});
//숫자키와 dot 만 입력
$(":input").filter(".only_number_dot").keypress(function(event){
if (event.which) {
if (event.which == 47 ) {
event.preventDefault();
}else{
if (event.which < 46 || event.which > 57) {
event.preventDefault();
}
}
}
}) .css("imeMode", "disabled");
$(":input").filter(".only_number_dot").keypress(function(event){
if (event.which) {
if (event.which == 47 ) {
event.preventDefault();
}else{
if (event.which < 46 || event.which > 57) {
event.preventDefault();
}
}
}
}) .css("imeMode", "disabled");
// 또는
$('.num_only2').css('imeMode','disabled').keypress(function(event) {
if(event.which && (event.which < 48 || event.which > 57) ) {
event.preventDefault();
}
}).keyup(function() {
if( $(this).val() != null && $(this).val() != '' ) {
var tmps = $(this).val().replace(/[^0-9]/g, '');
var tmps2 = tmps.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
$(this).val(tmps2);
}
});
});
댓글목록
등록된 댓글이 없습니다.