1 Reply Latest reply on Apr 26, 2006 6:32 AM by Newsgroup_User

    Setting word limit for a form text field

    sammiel Level 1
      Can someone tell me how to set a word limit within a field, rather than a character limit? Thanks in advance for your help!
        • 1. Re: Setting word limit for a form text field
          Level 7
          sammiel wrote:

          > Can someone tell me how to set a word limit within a field, rather than a character limit? Thanks in advance for your help!

          This can be done using javascript, but it's not foolproof.
          <script>
          MAX=50;
          </script>

          <input
          type="text"
          onkeyup=
          "if(this.value.split(' ').length>=MAX){
          alert('Only '+MAX+ 'words allowed');">

          You need to consider people pasting into the field, those with js
          disabled, and the annoying alert box.

          Mick