*** Text Box Problem ***

4 replies
Hi,

I'm trying to figure out how can be possible to automatically remove the exceeded text from a textbox when someone paste a longer text inside. The text box is limited to X characters.

If the text box is limited to 100 characters and if I paste a text which is 200 characters I want it to be automatically deleted.


Example: ezine articles title text box

I hope you can understand what I talking about

Any idea?
#box #problem #text
  • Profile picture of the author BenB969
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[1938142].message }}
    • Profile picture of the author Peter Hupuczi
      Originally Posted by BenB969 View Post

      Hi,
      Here's something useful I've found, using javascript:

      mediacollege.com/internet/javascript/form/limit-characters.html

      Is this what you're looking for?
      Yes! This is it.

      Is there any chance to have a similiar code in HTML?

      I have multiple text boxes and the limitation is vary

      Thanks anyway
      {{ DiscussionBoard.errors[1938262].message }}
  • Profile picture of the author Peter Hupuczi
    Thanks Ben!

    Problem solved
    {{ DiscussionBoard.errors[1940602].message }}
    • Profile picture of the author jminkler
      Originally Posted by Peter Hupuczi View Post

      Thanks Ben!

      Problem solved
      Even easier it to set the size attribute in the input tag. Of course, if your planning on inserting this into a database, you need to check that the value is also unde rthe max size before you try and insert it into the database. Anybody can modify your HTML/JS code on the fly if they wanted to.
      {{ DiscussionBoard.errors[1950419].message }}
      • Profile picture of the author BenB969
        Banned
        [DELETED]
        {{ DiscussionBoard.errors[1952487].message }}
        • Profile picture of the author jminkler
          Originally Posted by BenB969 View Post

          Don't know about 'size' attribute in textareas...
          HTML textarea tag

          I agree about the database though - should be checked in the database level too as javascript limitations can be skipped.
          Ahh textarea, not input type text .. yeah very true.

          Hmm ... but brings up an interesting solution that WYSIWYG editors use. You could probably do a hidden text input with it's size set, then onsubmit copy the values over. But, then the user wouldn't see what's not being sent so yeah the previous method works fine.
          {{ DiscussionBoard.errors[1952671].message }}

Trending Topics