SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to prevent user doing this (onkey down and up)

    hi there,

    i have a upload form, in which there's a text area, and i limited the text input to 500 using javascript like this:
    Code:
    onKeyDown="textCounter(document.listitem.description,document.listitem.counter,500)" 
    onKeyUp="textCounter(document.listitem.description,document.listitem.counter,500)"
    if works fine if type in your text, and surely it stop you type in any more when reach the 500 limit. but amazingly, i found a user manage uploaded about 2000 characters. i figured it out that if you don't type but copy and paste text into the text area, it will bypass the 500 limit.

    how can i make sure users never upload more than my limit?

    thanks

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    clip the text box to value.substring(0,500) onblur, or validate before you submit the form.

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank mrhoo, i'll try that.

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it will work when you add:
    "onMouseOut" event

    thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •