用jsp编写了一个用户留言页面。在留言内容 要求 字数不超过500字,增加剩余字数提示 功能。请问下怎么做到呢?
  还有这个功能 要能跨不同的浏览器都能使用。

解决方案 »

  1.   

    http://app.soche8.com/show/85.html
      

  2.   

    <s:textarea rows="4" cols="80" id="meno" 
    name="wfBusinessCardSeries.auditNote">
    </s:textarea>
    <font color="red">*</font>
    <font color="#808080" style="font: bold 13px Verdana;">剩余</font>
    <font color="#ff0080"
    style="font: normal 20 Georgia, 'Times New Roman', Times, serif">
    <span id="word">500</span>
    </font><font color="#808080" style="font: bold 13px Verdana;">字</font>
    <script language="javascript" type="text/javascript">
    $(document).ready(function(){
    $("#word").text( 500 - $("#meno").val().length );
    }); 
    $("#meno").keyup(function(){   
    if($("#meno").val().length > 500){
    $("#meno").val( $("#meno").val().substring(0,500) );
    }
    $("#word").text( 500 - $("#meno").val().length ) ; 
    });
    </script>