<script> function validate() { document.all.fld1.value = document.all.fld1.value.replace( "&", "& amp;" ) // Omit space after the & document.all.fld1.value = document.all.fld1.value.replace( "<", "& lt;" ) // Omit space after the & document.all.fld1.value = document.all.fld1.value.replace( ">", "& gt;" ) // Omit space after the & document.all.fld1.value="< pre>"+document.all.fld1.value+"< /pre>" // Omit space after the < 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>