?
Solved

XHTML Compliance - Microsoft word apostrophe

Posted on 2006-04-03
3
Medium Priority
?
471 Views
Last Modified: 2013-12-16
Hi I have a news page updated by a control panel which users just often copy and paste news items from a Microsoft Word document.  I want the output page to be html compliant and have a replace function on the page for the & symbol and a few others.  I cannot find one for the curly apostrophe that comes from the Word Document.

server.htmlencode will not work as i want to be able to include html links in the item.

Thanks
0
Comment
Question by:harris9999
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
kevp75 earned 2000 total points
ID: 16367164
I use the function below to get all HTML tags out of a textarea (or any other form field actually)

<%
Function rmvHTML(strString)
     Dim nCharPos, sOut, bInTag, sChar
     sOut = ""
     bInTag = False
     For nCharPos = 1 To Len(strString)
          sChar = Mid(strString, nCharPos, 1)
          if sChar = "<" Then
               bInTag = True
          end if
          if not bInTag Then sOut = sOut & sChar
          if sChar = ">" then
               bInTag = False
          End if
     Next
     rmvHTML = sOut
End Function
%>

you could also do something similar to this:
<script language="JavaScript">
<!--
function Del(Word) {
a = Word.indexOf("<");
b = Word.indexOf(">");
len = Word.length;
c = Word.substring(0, a);
if(b == -1)
b = a;
d = Word.substring((b + 1), len);
Word = c + d;
tagCheck = Word.indexOf("<");
if(tagCheck != -1)
Word = Del(Word);
return Word;
}
function Check() {
ToCheck = document.form.text.value;
Checked = Del(ToCheck);
document.form.text.value = Checked;
alert("This form is not set to submit anywhere so you will stay here.  But please notice that the text box's contents have been \"filtered\".");
return false;
}
// -->
</script>
</head>
<body>
<center><h1>Removing HTML</h1></center>
<p>This script is intended to ensure that people do not use HTML tags in form messages, Web forums, and so on. Type some text with HTML tags in the box below to try it out.</p>
<form name=form onSubmit="return Check()">
<textarea cols="50" rows="6" name="text"></textarea>
<br>
<input type="submit" value="Submit Entry">
</form>
0
 
LVL 3

Author Comment

by:harris9999
ID: 16369554
Hi,

I want to be able to include the html tag in the text area, so that a link could be added if required.  Thats why i can't use, server.htmlencode.  
I just noticed a typo in my initial message.  i want the output to be xhtml compliant.  
In the page where it is output i replace the & symbol etc

                  strText = replace(rs.fields("Details"),"&#8217;","'")
                  strText = replace(strText,"&","&amp;")
                  strText = replace(strText,"&#8217;","'")
                  strText = replace(strText,"&rsquo;","'")
                  strText = replace(strText,"‘","'")
                  strText = replace(strText,"&rsquo;","'")

i have tried to replace the various aprostophe's but i can't get one to replace the apostrophe which is pasted from a word document, and it is this one which breaks the xhtml compliance.
0
 
LVL 3

Author Comment

by:harris9999
ID: 16371663
strText = replace(strText, Chr(146),"'")

This fixed the problem
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question