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.
Regards,
Snigdha
Please Mark as Answer if my reply helped you.
Marked as answer by thaicarrot on Apr 18, 2012 10:25 AM
I think this function i wrote will do the things i want - strip whitespace, replace <> with html entities and escape quotes:
function sanitizeField(field){
//var field = document.getElementById("replaceText").value;
field = field.replace(/ /g,"");
field = field.replace(/[\\"']/g, '\\$&');
field = field.replace(/</g, '<');
field = field.replace(/>/g, '>');
//alert(field);
//document.getElementById("replaceText").innerHTML = field;
}
when i want to call the function - why do you think
< script type="text/javascript">
var example = 'to start here are < > " \';
exmaple = sanitizeField(example);
document.write(example);
< /script>
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?
thaicarrot
Contributor
5120 Points
1459 Posts
How do I create this fjunction?
Apr 16, 2012 07:55 AM|LINK
Hi,
http://msdn.microsoft.com/en-us/library/w3te6wfz.aspx
I need it base on jQuery.
Weera
somnathmali
Contributor
2816 Points
450 Posts
Re: How do I create this fjunction?
Apr 16, 2012 08:07 AM|LINK
try escape () and/or encodeURI().
encodeURI will be for the encoding URL
.NET Developer , Pune INDIA.
Please Mark As Answer If my reply helped you.
sargamlucy
Member
559 Points
164 Posts
Re: How do I create this fjunction?
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.
Regards,
Snigdha
Please Mark as Answer if my reply helped you.
thaicarrot
Contributor
5120 Points
1459 Posts
Re: How do I create this fjunction?
Apr 16, 2012 09:13 AM|LINK
Hi,
First thanks,
I think this function i wrote will do the things i want - strip whitespace, replace <> with html entities and escape quotes:
function sanitizeField(field){
//var field = document.getElementById("replaceText").value;
field = field.replace(/ /g,"");
field = field.replace(/[\\"']/g, '\\$&');
field = field.replace(/</g, '<');
field = field.replace(/>/g, '>');
//alert(field);
//document.getElementById("replaceText").innerHTML = field;
}
when i want to call the function - why do you think
< script type="text/javascript">
var example = 'to start here are < > " \';
exmaple = sanitizeField(example);
document.write(example);
< /script>
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?
Weera
Song-Tian - ...
All-Star
43699 Points
4304 Posts
Microsoft
Re: How do I create this fjunction?
Apr 17, 2012 06:54 AM|LINK
Hi,
Please refer to: http://www.w3schools.com/jsref/jsref_escape.asp.
<script type="text/javascript"> document.write(escape("Need tips? Visit W3Schools!")); </script>Feedback to us
Develop and promote your apps in Windows Store