ASP 글자수 제한하기
Posted at 2010. 10. 22. 18:43 | Posted in 프로그래밍/ASP, JavascriptPrivate Function GetString(str, strlen)
dim rValue
dim nLength
dim f, tmpStr, tmpLen
nLength = 0.00
rValue = ""
for f = 1 to len(str)
tmpStr = MID(str,f,1)
tmpLen = ASC(tmpStr)
if (tmpLen < 0) then
' 한글
nLength = nLength + 1.8 '한글일때 길이값 설정
rValue = rValue & tmpStr
elseif (tmpLen >= 97 and tmpLen <= 122) then
' 영문 소문자
nLength = nLength + 0.75 '영문소문자 길이값 설정
rValue = rValue & tmpStr
elseif (tmpLen >= 65 and tmpLen <= 90) then
' 영문 대문자
nLength = nLength + 1 ' 영문대문자 길이값 설정
rValue = rValue & tmpStr
else
' 그외 키값
nLength = nLength + 0.6 '특수문자 기호값...
rValue = rValue & tmpStr
end if
If (nLength > strlen) then
rValue = rValue & "..."
exit for
end if
next
getString = rValue
End Function
'프로그래밍 > ASP, Javascript' 카테고리의 다른 글
에디트플러스 정규식 사용하기 (0) | 2010.12.24 |
---|---|
XMLHTTP를 이용해서 값을 넘길경우 수신측에서 개행문자를 인식못할 경우 (0) | 2010.11.12 |
자바스크립트 숫자만 입력 받기(한글 입력 불가) (0) | 2010.10.22 |
MSXML2.ServerXMLHTTP 이용해서 웹페이지 읽기 (0) | 2010.02.03 |
체크박스 한개일때와 여러개일때 구분해서 오류없게 처리하기 (0) | 2009.07.02 |