John
John

Reputation: 145

Escape HTML and Javascript tags

I have a editable textbox. If I will enter alert('Hi'); , then it saves properly. After saving it will forward to a list page where that text box value will be a hyperlink. If we click on that hyperlink then alert displays. But we want to escape this. Can any one have the resolution for this ? Thanks in advance

Upvotes: 0

Views: 84

Answers (1)

Ahs N
Ahs N

Reputation: 8366

Before the text is saved for further processing or display, replace all "<" by "&lt;" and replace all ">" by "&gt;"

Upvotes: 1

Related Questions