I have a very simple form:
<form id="formRegister">
....
<input autocomplete="off" class="form-control input-sm required " id="Code" maxlength="10" name="Code" placeholder="VIP Code" style="width:150px;" type="text" value="">
....
<button id="btnVIPCodeLookup" type="submit" class="button-primary">Submit<i class="icon"></i></button>
</form>
And here's the script behind it:
// Landing page form submit
$("#formRegister").submit(function (e) {
e.preventDefault();
var code = $('#Code').val();
vipLookup(code);
});
function vipLookup(code) {
showBusy();
$.getJSON("/EventRegistration/EventRegistrationCodeLookUp", { code: code }, function (data) {
hideBusy();
if (data.Result == "true") {
$('#CodeResultSpan').text('');
$('#EncryptedCode').val(data.EncryptedVIPCode);
ShowLegal();
}
else
{
if (data.Result == "false") {
$('#CodeResultSpan').text('VIP Code not found. Please check the VIP Code you received and try again.');
}
if (data.Result == "used") {
$('#CodeResultSpan').text('VIP Code has been used.');
}
if (data.Result == "error") {
$('#CodeResultSpan').text('There was an error while looking up your VIP Code. Please try again.');
}
if (data.Result == "canceled") {
$('#CodeResultSpan').text('This VIP Code has been canceled.');
}
$('#Code').css('border-bottom', '1px solid #e03e3e');
}
});
}
The weird thing that I am seeing in some browsers (especially any iOS device, or when emulating an iOS device in Chrome), is that after the button is clicked, the form becomes disabled. I can't refocus into the textbox, and I can't click the button again.
If I remove e.preventDefault();
then the problem goes away, but this of course creates a new problem in that the page is refreshed, and the error messages vanishes.
You can see this in action here:
http://dev.walkup.audidriveusa.com/EventRegistration
Using Chrome, just type anything into the text box and click 'Submit'. You'll see the message. Then (if you can) change the text, and try to click 'Submit' again. It doesn't let you.