I have a problem on a production financial system where when users change the value of a numeric input field (so onchange function fires) and immediately click the form submit button, nothing happens - the submit button just remains active (pushed in) but form does not submit.
In real system I thought it was AJAX causing this but when I created this simplified version it still happens (I have included the button styles so you can see the stuck down button in Firefox). Happens in IE also but button does not remain stuck in.
i.e
If you click into field and then click submit it works (form submits).
If you click into field, change the value of field, click somewhere else (so onchange fires), and then click submit it works.
but..
- If you click into field, change the value of field, and then immediately click submit (without clicking anywhere else) it does not work (form does not submit but onchange function fires)
What am I doing wrong? I thought it was a focus problem or a return true false from function problem but it is beyond me now...
Can't ask financial users to click somewhere else after changing values before submission...
Using FF46 and IE11
EDIT: actually I notice that removing the alert from the onchange function fixes it, but in real system the function contains AJAX calls such as:
new Ajax.Updater ('amount_1','/path/page-ajax',{asynchronous:false,method:'post',parameters:'widget_name=amount_1&row=1&local_currency='+55+'&payment_id='+552+'¤cy_code_id='+$F('currency_code_id')+'¤cy_amount='+$F('amount')+'&update_amount_total_p=0'});
and the problem reappears when there is AJAX in the onchange function.
<html lang="en">
<head>
<script type="text/javascript">
function convertAmount(Obj)
{
alert('convertAmount');
}
</script>
<style>
input[type="button"], input[type="reset"], input[type="submit"] {
background: rgba(0, 0, 0, 0) linear-gradient(to bottom, rgba(246, 248, 249, 1) 0%, rgba(229, 235, 238, 1) 50%, rgba(215, 222, 227, 1) 51%, rgba(245, 247, 249, 1) 100%) repeat scroll 0 0;
border: 1px outset #eee;
border-radius: 4px;
color: #536c80;
cursor: pointer;
font-family: "Trebuchet MS",Arial,Helvetica,sans-serif;
font-weight: normal;
margin: 2px;
overflow: visible;
padding: 4px 15px;
}
input[type="button"]:hover, input[type="reset"]:hover, input[type="submit"]:hover {
background: rgba(0, 0, 0, 0) linear-gradient(to bottom, rgba(246, 248, 249, 1) 0%, rgba(237, 237, 192, 1) 50%, rgba(226, 226, 170, 1) 51%, rgba(245, 247, 249, 1) 100%) repeat scroll 0 0;
}
input[type="button"]:active, input[type="reset"]:active, input[type="submit"]:active {
background: rgba(0, 0, 0, 0) linear-gradient(to bottom, rgba(246, 248, 249, 1) 0%, rgba(237, 237, 192, 1) 33%, rgba(226, 226, 170, 1) 37%, rgba(245, 247, 249, 1) 100%) repeat scroll 0 0;
border: 1px inset #fff;
}
</style>
</head>
<body onsubmit="alert('submit');">
<form action="testbug2" method="post">
<input id="amount" type="text" maxlength="20" size="15" onchange="convertAmount(this);" value="2,612" name="amount">
<input type="submit" value="Save" name="formbutton:save">
</form>
</body>
</html>