<script language="javascript">
function checkCharacterSize(data, min, max) {
var total = 0;
for (var i = 0; i < data.length; i++) {
var a = data.charAt(i);
/* 한글인 경우 길이가 6 이다. */
if (escape(a).length >= 6) {
//total = total + 2;
//we are using utf-8 encoding in oracle,
//and korean character occupies 3 bytes in
//db
total = total + 3;
} else {
total = total + 1;
}
}
return total >= min && total <= max;
//alert(total);
//return total;
}
function getCharacterSize(data) {
var total = 0;
for (var i = 0; i < data.length; i++) {
var a = data.charAt(i);
/* 한글인 경우 길이가 6 이다.--Oracle저장길이 */
//alert(escape(a));
if (escape(a).length >= 6) {
//total = total + 2;
//we are using utf-8 encoding in oracle,
//and korean character occupies 3 bytes in
//db
total = total + 3;
} else {
total = total + 1;
}
}
//return total >= min && total <= max;
alert(total);
return total;
}
</script>
<input type="text" name=txt><input type=button value=btn οnclick="javascript:getCharacterSize(txt.value);"/>