View Full Version : How to find certain characters in a string

02-09-2007, 10:21 PM
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?


02-09-2007, 10:59 PM
var replace = "something to replace with"
var search = string.replace(/</,replace)
string.value = search