Replace single quotes entered in forms

script written by

Description:

This handy function will replace the ' character entered into a web form, with an ascii equivalent. This is essential for posting and retrieval of single quotes to and from a database. This script is just a "snippet" - it indicates how you would incorporate the function with the request.form collection, but isnt a fully working example.

'form variables
dim formVar

'encapsulate form element with quote replacing function
formVar = QuoteReplace(Request.Form("input"))

'function code
Function QuoteReplace(formVar)
QuoteReplace = Replace (formVar, Chr(34),""")
QuoteReplace = Replace (QuoteReplace,"'","'")
End Function 



Remember, if you get stuck or need to ask any questions, register with the forums and tell us about it!

Partners Partners