Reputation: 603
I have a text area on my site which shows the user a certain value. The problem is that when i click the text area (form) and press enter, it shows a 404 error. How can I edit my existing html code to remove the submit/enter action, so that the page doesnt lead to a 404?
Here's my code:
<input type="text" name="postLink" size="48" value="This is a value!" />
Upvotes: 1
Views: 212
Reputation: 2757
The answer depends a little on what you are trying to do... if you can clarify the intent of the question, it will help us clarify our answers.
If you are doing this to allow for new lines in the box, you may want to look at using a <textarea>
instead of <input type="text" />
. (And even if you're doing this for other reasons, this may still be a better option)
If you're doing this to just display something (and not allow for edits/submissions) you may want to disable the form item (add disabled="disabled"
to the element). If this is your goal, there may be some other/better ways to do this.
Depending on what you're doing, you could also add a little JavaScript to the page to capture and ignore the return key - just keep in mind this does no good if they have JavaScript disabled, and it may cause some undesirable side-effects like not being able to add new lines to a text area. The following, and dozens of variants can be found floating around the 'net.
document.onkeydown = function(){
if(window.event.keyCode==13) return false
}
You could remove the submit button, but IE will still submit the form if there is only one element in the form, and FireFox will always submit the form uppon pressing Enter. I don't recall what Chrome and Opera do, but the point remains that deleting the submit button will not give you what you want across the board.
Upvotes: 0
Reputation: 11274
You should have an <input type="submit>
field somewhere. Delete that. Or, remove the encapsulating <form>
tag.
Upvotes: 3