SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member fungens284's Avatar
    Join Date
    Jul 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    not allowing html in text box

    i am making this comment thing and i did not want to allow html to be posted is there any way that i can make it do that by not letting them put html in the text box?

  2. #2
    SitePoint Member
    Join Date
    Jun 2006
    Location
    Los Angeles
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There certainly is - but this might be better suited for PHP so that it can't be disabled by a possible malicious user.

    http://us2.php.net/strip_tags

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u can prevent html submit with
    if(document.getElementById("bla").value.match(/\<|\>/)) // do something
    or u just use a server side script to strip html tags..
    cheers

  4. #4
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I require the same thing and have no idea how to implement the following code

    if(document.getElementById("bla").value.match(/\<|\>/)) // do something

    here is a snippet of my current form

    <p>Message/p>
    <p>
    &nbsp;<!--webbot bot="Validation" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="255" --><textarea rows="5" name="Comments" cols="50" onkeyup="if (this.value.length > 254) { alert('Character limit has been reached!'); this.value = this.value.substr(0,254); }"></textarea></p>
    <p><input type="submit" value="Submit" name="B2"></p>
    </form>

    Regards

    Darren

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to do this so that you can recomend to the user that they shouldn't post html, then javascript is fine.

    If you want to do this to prevent them from posting html, then you must enforce this in the serverside script which receives the form submission.


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
  •