Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Don't display HTML effect on browser
Message
From
29/11/2002 04:53:56
 
 
To
29/11/2002 01:16:54
General information
Forum:
Internet
Category:
HTML
Miscellaneous
Thread ID:
00728100
Message ID:
00728119
Views:
22
>Dear all,
>
>I have a form to let user type their message, and it will display to the screen after they post (it just like a Chart Room).
>
>But I don't want the input text having the HTML effect when it display, (even users have type HTML tag into the input box, then the screen only display same thing(not HTML effect) they type after they post it).
>
>Please give me some hints.
>
>Thanks
>Aston

Michel's post shows how to remove the HTML tags, but if you want to show the tags that have been typed in, then before they post the string, surround the text input with < PRE > & < /PRE > tags, this can be done in the onsubmit event of the form :
<script>
function validate()
{
  document.all.fld1.value="<"+"pre>"+document.all.fld1.value+"</"+"pre>"
  return true
}
<script>

<form method="post" action="..." onsubmit="validate()">
<input type="text" id="fld1" name="fld1"></input>
<input type="submit" name="guestsubmit" value="Submit">Click to send
</form>
Note that you don't need to split the added tags ("<"+"pre>" & "<"+"/pre>") - thats due to a limitation of UT. You can also do other validation in the function (eg has user filled in all required fields) & if you don't want the form to be sent then return false

Also note, if your form is being submitted via a third-party CGI script (eg that of your ISP) you may find that they automatically strip any HTML tags from the incoming post for security reasons - mine does.
Len Speed
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform