DJ메탈짱™의 Free Style

[Javascript] 문자열 한글 포함 체크, 정규식 본문

일(job)/FRONT

[Javascript] 문자열 한글 포함 체크, 정규식

뽀&쏭 2016. 1. 19. 13:28



/*********************************************************************

   : 문자열에 한글이 포함되어 있는지 확인.

작성자 : bhchoi

작성일 : 2012/02/23

------------------------------------------------------------------------

한글이 있으면 true

한글이 없으면 false

***********************************************************************/

function checkKorean(objStr) {

    for (i = 0; i < objStr.length; i++) {

        if (((objStr.charCodeAt(i) > 0x3130 && objStr.charCodeAt(i) < 0x318F) || (objStr.charCodeAt(i) >= 0xAC00 && objStr.charCodeAt(i) <= 0xD7A3))) {

            return false;

        } else {

            return true;

        }

    }

}