Advanced Search

Results 1 to 2 of 2

Thread: How to find certain characters in a string

  1. #1
    Join Date
    Jan 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to find certain characters in a string

    Currently I have someone typing into an html textfield. I want the javascript to catch any "<" or ">" characters and replace them with something. Currently when someone adds a "<" followed by a letter, the site freezes and I guess it is because it thinks someone is trying to input html tags.

    So, could someone please tell me how to first of all find the "<" and ">" characters in a string, and then replace those with another character?

    Thanks!

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    var replace = "something to replace with"
    var search = string.replace(/</,replace)
    string.value = search
    - Mike

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
  •