Saturday, October 8, 2016

Classic Asp - remove enter carriage return character in textarea for valid json

You would need to replace vb carriage return with br tag, Following is the function which can solve all your purpose:

Function Escape(sString)
strReturn = sString
  if(len(sString) > 0) then
    'Replace any Cr and Lf to <br>
    strReturn = Replace(sString , vbCrLf, "<br>")     : 'visual basic carriage return line feed     ***********\
    strReturn = Replace(strReturn , vbCr , "<br>")     : 'visual basic carriage return               *********These 3 are line breaks hence <BR>
    strReturn = Replace(strReturn , vbLf , "<br>")     : 'visual basic line feed          ***********/
    strReturn = Replace(strReturn, "'", "\'")          : 'Single quote changed to 2 single quotes ASP knows what to do
end if
    Escape = strReturn
End Function

0 comments:

Post a Comment

Powered by Blogger.

Best Price Amazon Portal