Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Skipping certain areas for validation, it is possible? 2

Status
Not open for further replies.

Xaqte

IS-IT--Management
Oct 4, 2002
971
US
I have the following part of my html code that doesn't validate:
Code:
<textarea rows="10" cols="60" name="Home">
<p>The cow jumped over the moon</p>
</textarea>

I know why it doesn't validate. However, is there a way to flag an area to ignore when validated?
I was thinking something along the lines of:
Code:
<nocode>
<textarea rows="10" cols="60" name="Home">
<p>The cow jumped over the moon</p>
</textarea>
</nocode>

Any thoughts/suggestions would be greatly appreciated!

X
 
It's not valid, it shouldn't validate. If a workarround like that works, the validator should be shot... As then anyone can claim valid code by putting
Code:
<nocode>
</nocode>
arround their site.

I'm not saying a page that isn't 100% standards compliant is neededly evil... I'd suggest trying to validate with an earlier standard, when things like that were allowed -- just a suggestion and a guess.

[plug=shameless]
[/plug]
 
Just as I thought... Oh well. I understand the reasoning behind it... although it makes it a little difficult to have a simple content management system to be completely valid.

Thanks anyway!
 
I know. I am making modules for the CMS that I use, and the developer doesn't care much for w3 standards. It's a nice system, but I'm really giving thought to starting a new CMS that the modules I created already will work in.

[plug=shameless]
[/plug]
 
Foamcow,
I'm trying to make a "simple" content management system for a site. I'm just pulling the same data that I used for viewing from a database. This data includes html tags. Thus, when I provide an admin interface I pull the same data & throw it in a textarea in a form. This allows the end user (with basic html knowledge) to pull this up & edit their content any way they want without involving me.

Now, the alternative (correct me If there is a better way):
Parse the html from the database, and for each tag with data in it (not br, ul...) send it to my template with its own textarea for the form.

Much thanks for everyone's thoughts/experience!

Xaqte ( Pronunciation: 'ek-si-"kyüt )
 
So are you saying that the problem is people using non permissable tags in the textarea when they edit things?


Sorry about getting your name wrong... I misread it, my eyes are all puffy and sore due to hayfever lol

Foamcow Heavy Industries - Web design and ranting
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
I wonder what possesses people to make those animated gifs. Do you just get up in the morning and think, "You know what web design r
 
Foamcow,
Not necessarily... I was using the "non permissable tags" intentionally for the sake of simplicity. I found it difficult to predine the content layout (paragraphs, lists, headings). Again, this was just for the sake of simplicity. I have to say I've been fighting this and other html entities for a short while with this. I realize I could create a larger configuration/management system with multiple tables & queries in my database. However, I found myself asking myself this for a very simple & small site... how far do I go to get 100% validation?

No fret about the name... I sometimes wonder if I should've thought that one out so long ago; lol. BTW, how did you pick your handle?

By the way... I really like your work!

X
 
Hmmm...

All this talk of databases and queries. I think you are losing sight of the problem (or more likely I don't understand it).

Validation simply means that the tags and structure of the document conform to a standard.
You can read/write whatever you like in a database table.
Are you filling the database with actual HTML or just text that gets flowed into an existing structure?

My own site, uses a simple CMS to store "rant" entries in a database table. The pages validate.
This is because when I write the entries I do so with valid markup. I do a string replace on paragraph breaks and write a <p> at the start, a </p> at the end and a </p><p> pair for every return character.

So, is the problem that the code you are flowing your stored content into doesn't validate? or is it that the stuff stored in the database doesn't validate?

Incidentally, the code snippet you supplied is perfectly legitimate with some DOCTYPES. With XHTML I beleive the name attribute isn't permitted, but that's all that is wrong with it.

Can you give us a link to an example page?

Foamcow Heavy Industries - Web design and ranting
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
I wonder what possesses people to make those animated gifs. Do you just get up in the morning and think, "You know what web design r
 
It should validate if you change it to:
Code:
<textarea rows="10" cols="60" name="Home">
&lt;p>The cow jumped over the moon&lt;/p>
</textarea>
For a decent CMS, though, I'd recommend trying to keep markup out of it wherever possible - the whole point of CMSs is generally to hide HTML from the end-user.

Instead, I'd convert all single line breaks into <br>s, and multiple ones into paragraph breaks. Then maybe have some simple markup along the lines of TGML that you can parse into HTML.

A further alternative would be to use a wysiwyg control like the one at .

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Foamcow,
Incidentally, the code snippet you supplied is perfectly legitimate with some DOCTYPES.

May I ask if you know which ones?

Chris Hunt,
I was really trying to stay away from java... but that wysiwyg control is really tempting. Have you used it before?

Thanks,

X
 
I think HTML4 allows the name attribute. I've not coded to HTML4 spec for a long time though so I may be wrong.

There are a number of standards compliant wysiwyg controls around. Might be the solution for you.

Foamcow Heavy Industries - Web design and ranting
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
I wonder what possesses people to make those animated gifs. Do you just get up in the morning and think, "You know what web design r
 
This is my doctype:
Code:
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
 
Foamcow: It's not the name attribute it's objecting to, it's nesting a <p> element inside a <textarea>.

Xaqte: It's not Java, it's Javascript. Two very different things, confused with eachother by marketing people. I've not used it myself though.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Chris Hunt: Doh! Javascript is what I meant.

To both:
Thanks for all your thoughts/suggestions... a star for each of you. If you have any more to add, please do so.


X
 
lol.. it's only now that I understand the actual problem!

you could try foing a regexp replace on < and > if they appear with 1 or 2 characters between then. Then convert them to &gt; and &lt;

But as Chris said, you are probably better off not having ANY HTML in your stored data.

Foamcow Heavy Industries - Web design and ranting
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
I wonder what possesses people to make those animated gifs. Do you just get up in the morning and think, "You know what web design r
 
Your language probably has the equivilent of strip_html(...) or convert_html(...). It's a bad idea to allow HTML in a CMS anyway, as a user could do something like:
Code:
<img src="some_eye_sore.jpg" width="9000px" length="90000px" />
or better yet:
Code:
<a href="

Just a thought.

[plug=shameless]
[/plug]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top