반응형
<script>
var checkUnload = true;
const countingWords = (category) => {
if (category == 'one_line') {
const currentOneline =document.getElementById("one_line").value.length;
document.getElementById("current-one-line-num").innerText = currentOneline ;
if(currentOneline>40){
alert('40자를 넘길 수 없습니다!');
const value = document.getElementById("one_line").value;
document.getElementById("one_line").value= value.split('',38).join('');
document.getElementById("current-one-line-num").innerText = 38 ;
}
} else {
const currentOneline =document.getElementById("introduction").value.length;
document.getElementById("current-introduction-num").innerText = currentOneline ;
if(currentOneline>200) {
alert('200자를 넘길 수 없습니다!');
const value = document.getElementById("introduction").value;
document.getElementById("introduction").value = value.split('', 198).join('');
document.getElementById("current-introduction-num").innerText = 198;
}
}
}
function onSubmitFunc() {
checkUnload = false;
}
$(window).on("beforeunload", function () {
if (checkUnload) return "이 페이지를 벗어나면 작성된 내용은 저장되지 않습니다.";
});
$('input[type="text"]').keydown(function () {
if (event.keyCode === 13) {
event.preventDefault();
}
;
});
</script>
반응형