I have a problem with a hidden submit button. I have an input field I use for an Ajax(jQuery) chat, people should enter text and press enter to submit. This works fine in Firefox but not in chrome, I think it treats it as if it’s not there.
I’m using the following code:
$('#CommentChatForm').submit(function(event){
...
}
And I use this to hide the submit button:
$('#CommentChatForm input:submit').hide();
Which makes the HTML look like this:
<div class="submit">
<input type="submit" value="Submit" style="display: none;">
</div>
I’ve also tried using keypress() by adding the following on top:
$('#CommentMessage').keypress(function(e){
if(e.which == 13){
$('#CommentChatForm').submit();
}
})
This makes it work fine in Chrome but in Firefox it causes it to submit twice instead of once.
If you use the keypress handler you won’t need the hidden submit button, so just remove it.