뒤로가기
그냥 script event
드래그이벤트
var isDragging = false;
var previous_x_position = 0;
var previous_y_position = 0;
$(".discovery").mousedown(function(e) {
previous_x_position = e.pageX;
previous_y_position = e.pageY;
$(window).mousemove(function(event) {
isDragging = true;
var x_position = event.pageX;
var y_position = event.pageY;
$(window).unbind("mousemove");
});
}).mouseup(function(e) {
var wasDragging = isDragging;
isDragging = false;
var x_position = e.pageX;
var y_position = e.pageY;
$(window).unbind("mousemove");
});
' , " 따옴표 입력불가처리
$("input[name='sp_name']").on('keyup', function (e) {
let str = $(this).val();
let reg = /(['"])/gim;
str = str.replace(reg, "");
$("input[name='sp_name']").val(str);
});
바이트 글자수 제한
function fn_checkByte(obj){
const maxByte = 100; //최대 100바이트
const text_val = obj.val(); //입력한 문자
const text_len = text_val.length; //입력한 문자수
let totalByte=0;
for(let i=0; i<text_len; i++){
const each_char = text_val.charAt(i);
const uni_char = escape(each_char); //유니코드 형식으로 변환
if(uni_char.length>4){
// 한글 : 2Byte
totalByte += 2;
}else{
// 영문,숫자,특수문자 : 1Byte
totalByte += 1;
}
}
if(totalByte>maxByte){
alert('최대 100Byte(한글 50자)까지만 입력가능합니다.');
let tmp_str = textRightDel(text_val , maxByte)
obj.val(tmp_str);
}
}
function textRightDel(str, maxByte) {
for(b = i = 0; c = str.charCodeAt(i);) {
b += c >> 7 ? 2 : 1;
if(b > maxByte){
break;
}
i++;
}
return str.substring(0,i);
}