$(document).ready(function() {
//정수만
$('.num_only').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, '') );
}
});
//금액
$('.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 tmps = $(this).val().replace(/[^0-9]/g, '');
var tmps2 = tmps.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
$(this).val(tmps2);
}
});
//소수점포함
$('.num_only3').css('imeMode','disabled').keypress(function(event) {
if(event.which && ( event.which < 45 || event.which > 57) ) {
event.preventDefault();
}
}).keyup(function(){
if( $(this).val() != null && $(this).val() != '' ) {
$(this).val( $(this).val().replace(/[^\.0-9]/g, '') );
}
});
});
'JSP·script·jquery' 카테고리의 다른 글
jstl c태그 과 스크립틀릿 사이의 데이터 공유 (0) | 2014.04.02 |
---|---|
스크립트를 이용한 필드 암호화 및 복호화 (0) | 2014.03.10 |
ajax 사용 후 json 데이터 jsp 에서 핸들링 (0) | 2013.12.01 |
jquery ajax 데이터 json으로 받기 (0) | 2013.11.28 |
jquery 부모창 스크립트 호출 및 값 넘기기 (0) | 2013.11.27 |