Code: Select all
<form action="./" method="post" id="redir">
<textarea maxlength="255" rows="1" cols="17" name="chat_version" class="overflow:hidden;" wrap="off" onKeyPress="submitenter(event)">test</textarea>
</form>
<script type="text/javascript">
function submitenter(e){
var keycode;
if(window.event){
keycode = window.event.keyCode;
}else if(e){
keycode = e.which;
}else{
return true;
}
if(keycode == 13){
document.getElementById('redir').submit();
return false;
}else{
return true;
}
}
</script>
What this does is simply turn a <textarea> into a <input type="text">
Why would I do this? The reason is this:
As i'm sure everyone knows, a user can input literally anything into a field. After they hit "submit", it's our job to sort it out and throw away or change the "bad"
The problem with text input: to auto-populate it, we use value="". So what if the user entered a "? WHOOPS! No matter how you code or form it - without changing the character - your nice neat form just wound up destroyed.
This is why I chose the textarea. However, it's large and a bit sloppy, so if anyone has any ideas on how to allow every character under the sun into a text input without destroying it, let me know. It would be appreciated