Employer Search button steals all enter/return/cr input and submits form

Options
We noticed that the Employer Search button is configured to steal all enter/return/cr input and then submit the form unexpectedly, which refreshes the page confuses the user if they were trying to add a carriage return to the Comments textarea. 


Is this normal behavior? We see the javascript causing it, but can not find a location to edit or disable it from automatically submitting.

It doesn't exist in the Page Builder or Page Wrapper Editor, and seems hard-coded into the element when adding it to a giving page.


Example:
https://giving.uchicago.edu/site/Donation2?df_id=1681&mfc_pref=T&1681.donation=form1


Source within the HTML:

<script type="text/javascript">

if (document.layers) {

document.captureEvents(Event.KEYDOWN);

}

document.onkeydown = function (evt) {

var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;

if (keyCode == 13) {

button = document.getElementById("donor_matching_employersearchBtn");

button.click();

return false;

} else {

return true;

}

};

</script>
Tagged:

Comments

  • Can you add your own function and prevent this one from firing? Something like:

    document.onkeydown = function (evt ) {<br /><br/>var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;<br /><br/>if (keyCode == 13) {<br /><br/>evt.preventDefault();<br /><br/>evt.stopPropagation();.<br /><br/>return false;<br /><br/>} else {<br /><br/>return true;<br /><br/>}<br /><br/>}


    Nice form so far. I love the dropdown filtering.

Categories