Try using JavaScript like the following:

<script language='JavaScript'>
function numOfBytes(inputString) {
  if (inputString == null) {
    return -1;
  }
  var byteCount = 0;
  var leng = inputString.length;
  for (var i = 0; i < leng; i++) {
    if (inputString.charCodeAt(i) > 127) {
      byteCount += 2;
    }
    else {
      byteCount++;
    }
  }
  return byteCount;
}
</script>

  Just for your reference.
  (BTW. This post is unfit here, since it has
 nothing to do with JSP-INTEREST. ^_^)
----------------------------------------
Romantic Emotionalists Must Endure Ordeals.
Email1(200103): [EMAIL PROTECTED]
Email2(200011): [EMAIL PROTECTED]
Email3(199908): [EMAIL PROTECTED]
Email4(199906): [EMAIL PROTECTED]
Office: Tokyo, Japan http://www.gecapital.com
Home: Dalian, Liaoning, China (Hometown: Hunan)
----------------------------------------


-----Original Message-----
From: Priya Ranjan Dash [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 3:40 PM
To: [EMAIL PROTECTED]
Subject: character to byte
Importance: High


Is there any way to find number of bytes entered in a HTML field using
client side scripting???
Any help will be greatly appreciated.

-Ranjan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to