Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 17, 2012 06:54 AM by Song-Tian - MSFT
Apr 16, 2012 07:55 AM|LINK
I need it base on jQuery.
Apr 16, 2012 08:07 AM|LINK
try escape () and/or encodeURI().
encodeURI will be for the encoding URL
Apr 16, 2012 08:11 AM|LINK
Can you please give a bit more explanation. I probably have done something like this in my project if I understand that your problem is with the "," and "." tags. But please be descriptive.
Apr 16, 2012 09:13 AM|LINK
I think this function i wrote will do the things i want - strip whitespace, replace <> with html entities and escape quotes:
//var field = document.getElementById("replaceText").value;
field = field.replace(/ /g,"");
field = field.replace(/[\\"']/g, '\\$&');
field = field.replace(/</g, '<');
field = field.replace(/>/g, '>');
//document.getElementById("replaceText").innerHTML = field;
when i want to call the function - why do you think
var example = 'to start here are < > " \';
exmaple = sanitizeField(example);
doesn't seem to work? that is, it just return the original string. when I used the alert in the function, it was doing the right action.
also, do you think this is about an hour's worth of work?
Apr 17, 2012 06:54 AM|LINK
Please refer to: http://www.w3schools.com/jsref/jsref_escape.asp.
document.write(escape("Need tips? Visit W3Schools!"));