how to limit HTML input in a form box

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
SL-Cowsrule
Forum Newbie
Posts: 13
Joined: Sat Oct 12, 2002 5:08 pm

how to limit HTML input in a form box

Post by SL-Cowsrule »

I was just wondering if you could do this, and if so, how.

Thanks,
CoW
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

e.g.

Code: Select all

<input type="text" name="xyz" maxlength="20" />
But the client may choose to ignore it or the user can transmit the data in another way, so you have to also check the input server-side (e.g. by strlen()) if necessary.
SL-Cowsrule
Forum Newbie
Posts: 13
Joined: Sat Oct 12, 2002 5:08 pm

Post by SL-Cowsrule »

sorry for not making myself clear, i meant if i could disable the persons ability to use html code, or have the code be taken out or something, or maybe not displayed from a database. Im not sure if i can use an HTML function or if this is php.
i looked at w3c.org under the form syntax and didnt see anything... so imguessing this is php.
Thanks,
CoW
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

yep, php has great functionality for that. see http://php.net/strip-tags
Sunthas
Forum Newbie
Posts: 9
Joined: Sun Dec 08, 2002 12:43 am

Post by Sunthas »

Using MySQL and PHP and Apache latest, I have only had to convert apersands and use the addslashes command to get the data to store and retrieve correctly.

For example I would type in something like:

Code: Select all

So and so said this "Blah Blah Blah!" If you want to read more about blah check it out <a href='http://www.blah.com/something.php?one=1&two=2'>here</a>.
Ofcourse when this gets pulled out later the HTML is converted which is what I want and gets displayed correctly. The slashes that might be added before the Single or Double Quotes never have to be changed again. The ampersand would be fine left alone in the database and for display purposes seems to display fine in IE6, but for HTML401Transitional compliance needs to be changed to &
Post Reply