봄날을 찾아 떠나는 여정의 끝에서..

2009/06/12

TinyMCE 웹에디터와 submit

분류: javascript, web plug-in — 동천홍 @ 9:08 am

TinyMCE Editor의 null에대한 유효성 체크

구글링을 통해.. 찾아낸 방법을 소개한다.

TinyMCE Editor는 submit하기 전에 tinyMCE.triggerSave();를 실행하여 textarea에 값을 바인드 시켜주어야 한다.

아래는 간단하게 에디터의 생성과 유효성체크에 대한 코드를 적어놓는다.

에디터 생성

tinyMCE.init({
// General options
id : “content1″,
mode : “textareas”,
theme : “advanced”,
language : ‘ko’,
// Theme options
theme_advanced_buttons1 : “bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect”,
theme_advanced_buttons2 : “”,
theme_advanced_toolbar_location : “top”,
theme_advanced_toolbar_align : “left”,
theme_advanced_resizing : true
});

유효성체크

function check_CT_AA(frm){
tinyMCE.triggerSave();
if(frm.title.value == ” || frm.title.value == null){
alert(‘제목을 입력하세요.’);
frm.title.focus();
}
else if(trim(frm.content.value) == ”){
alert(‘내용을 입력하세요.’);
}
else{return true;}
return false;
}

테마: Silver is the New Black. WordPress.com 제공.

팔로우

모든 새 글을 수신함으로 전달 받으세요.