Clean way to prevent enter button submitting a form

The following code solved my issue:

http://www.itorian.com/2012/07/stop-from-submission-posting-on-enter.html

<script type="text/javascript">
    //Stop Form Submission of Enter Key Press
    function stopRKey(evt) {
        var evt = (evt) ? evt : ((event) ? event : null);
        var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
        if ((evt.keyCode == 13) && (node.type == "text")) { return false; }
    }
    document.onkeypress = stopRKey;
</script>

Put this in the master page or just in the pages that you want.


Set the UseSubmitBehavior property on the submit button to FALSE. (found the solution here)