Form pressing Enter not the same as clicking Save

I have a form that when I click Save does what I want… but when I type in the field and press the “enter” key the screen flashes like its doing something, but it doesn’t process my code like clicking “Save”.
I have searched the forums but not found exactly what I should do… I found a few people who use javascript code to manipulate what the “enter” key does… but I’m not sure how to get a Form to execute javascript onload.
The reason I need it, is for USB IR scanners that will scan a barcode and press “enter” at the end of the code in order to enter data.
My database updates occur in an onValidateSuccess event if that makes any difference.
Thanks!

you can always use jscript code by doing something like this in the onloadevent of the form


echo "
<script>
	
    $(function() {
		
        //Some code here
     }
       
</script>";

as kafe says - also for a bit more detail see this post:

http://www.scriptcase.net/forum/archive/index.php/t-4113.html

Uses “Enter” as the example.

Here you have to add an event listener to a edit. Use firebug to know the class of your edit.

Try to echo something like this:

$(function () {
		document.getElementById("busc0ador").addEventListener("keypress", function(e){
			if (e.keyCode === 13) {
				nm_alterar(); // <-- Search on forum (or use Firebug and insepct Save button) the JS function to save. I don't remember exactly
				e.preventDefault();
			}
		},false);
});