kvarnerexpress 0 Report post Posted August 30, 2005 I have a form on my page. I do not have a submit button, but when I hit enter on my text field, it is like I am clicking on a submit button. My page refreshes to the original state, and my values are reset.I found this out because I made a submit button and tried it.Is there a way to get around this? I am trying to use a javascript that captures the key strokes. That works, but then the submit like event still fires after my code runs, nullifying any changes my code has made.html4strict Code: 1. <form name="FormPictureInfo"> 2. <table cellpadding="0" cellspacing="4" border="0" align="center"> 3. <tr> 4. <td align="center"><input type="text" name="ProductCode" size="22" maxlength="256" value="default" onFocus="clearBox(this);" /></td> 5. <td align="center"><div class="infotitle">Product:</div></td> 6. <td align="center"><div class="infotitle">Comments:</div></td> 7. <!--<td align="center"><div class="infotitle">Picture Date:</div></td>--> 8. <td valign="top" align="center"><div class="Descriptor" id="BagSize">Bag Size</div></td> 9. </tr> 10. <tr> 11. <td><table cellpadding="2" cellspacing="6" border="0"> 12. <tr> 13. <td valign="top" align="center"><input type="button" value="Display Picture" onclick="FillDataShowPic(document.FormPictureInfo.ProductCode.value);"/></td> 14. </tr> 15. <tr> 16. <td valign="top" align="center"><input name="ZoomButton" type="button" value="ZOOM" onclick="Zoom(document.getElementById('ProductCodeDisplay').innerHTML);"/></td> 17. </tr> 18. </table></td> 19. <td valign="top"><table cellpadding="0" cellspacing="2" border="0"> 20. <tr> 21. <td align="center"><div class="Descriptor" id="ProductName">Product Name</div></td> 22. </tr> 23. <tr> 24. <td align="center"><div class="Descriptor" id="ProductCodeDisplay">Product Code Display</div></td> 25. </tr> 26. <tr> 27. <td valign="top" align="center"><div class="Descriptor" id="PictureDate">Picture Date</div></td> 28. </tr> 29. </table></td> 30. <td valign="top" align="center"><div class="DescriptorArea" id="ProductComments">Product Comments</div></td> 31. <td><table cellpadding="0" cellspacing="2" border="0"> 32. <tr> 33. <td align="center"><div class="Descriptor" id="SetPoint">Set Point</div></td> 34. </tr> 35. <tr> 36. <td valign="top" align="center"><div class="Descriptor" id="Density">Density</div></td> 37. </tr> 38. <tr> 39. <td valign="top" align="center"><input type="button" value="Close" onclick="self.close();"/></td> 40. </tr> 41. </table></td> 42. </tr> 43. </table> 44. </form> Thanks,kvarnerexpress Share this post Link to post Share on other sites
cse-icons 0 Report post Posted August 31, 2005 If I understand properly, u do not wish the form to submit on "Enter".To prevent this you can have a <form action="" onSubmit="func()"> The onsubmit event would fire on pressing enter, which would call the javascript function "func()". In this function u can do the processing and submit if u want or else just leave it.Cheers. Share this post Link to post Share on other sites
Lozbo 0 Report post Posted September 6, 2005 <form action="" onSubmit="func()"> 180709[/snapback] I think you could also put a submit button with the atribute ... <input type="submit" onClick="func()">... which is suposed to do exacly the same (even if you omit the 'onSubmit' atribute on the form tag). Share this post Link to post Share on other sites
reatum 0 Report post Posted October 4, 2005 all you need to do to keep the form from submitting on enter is <form name="whatever" onSubmit="return false;"> then use javascript to tell your form what to do with some sort of listener or an onclick function on a submit button like lozbo said. Share this post Link to post Share on other sites