Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: certain words in a text box, disable the submit button

  1. #1
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default certain words in a text box, disable the submit button

    If someone typed a swear word in a text box - the submit button would then be disabled (straight away) until they removed the word? - how would i do that?
    Last edited by lankinator; 04-06-2007 at 06:16 AM.

  2. #2
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It depends whether you want the submit button to be disabled as soon as the user types the word or when the user loses focus on the textbox.

  3. #3
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    as soon as the user types the word please.

  4. #4
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    attach an onkeydown handler to the textarea and keep checking if the contents of the textarea contains any of the bad words.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,953
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    I think onkeyup would be a better choice but, it would be much more efficient, if the submit process is governed by a function, to simply abort the submit function if a bad word was found. Or, have a onmouseover event on the submit button to disable it if off color language was found.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1: yep, the onkeyup handler would certainly be better.

    lankinator: But implementation of a bad-word filter with javascript would be a very bad idea(with growing tools like firebug). An example case: if one has stored the bad-words in an array, any person with sufficient javascript knowledge could simply modify the array to be empty which would not lead to a very good filter.

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Or just disable Javascript. It's acceptable as a user interface feature, but the definitive checking should be performed server-side.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I agree with Twey, I think server-side is the way to go.

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,953
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey View Post
    Or just disable Javascript. It's acceptable as a user interface feature, but the definitive checking should be performed server-side.
    How will disabling javascript disable the submit button? I agree that the final check to prevent swear words should be done server side. However, I am not aware of any server side method that will disable the submit button at either the moment that a user enters a 'bad' word or at the moment the user moves the mouse to submit.

    I'm not saying that it cannot be done, I'm just fairly certain that it cannot be done. I'm always willing to learn new things.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1: I think(but am not sure though), Twey meant that the javascript-swear-word-blocker won't work in cases where javascript is disabled, right Twey?

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
  •