In Safari, there is a strange issue occurring with a text field used for emails. When entering text and trying to edit by moving the cursor, new characters are automatically placed at the end of the text. It seems that the problematic code causing this behavior is the following:
function clearErrors() {
var authError = document.getElementById("authError");
var error = document.getElementById("error");
if (authError !== null) {
document.getElementById("authError").innerHTML = "";
}
if (error !== null) {
document.getElementById("error").innerHTML = "";
}
function postOnReturn(e) {
document.forms[0]['pf.username'].value = document.forms[0]
['pf.username'].value.trim();
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13) {
if ($isCustomerInternal == 'false')
if ($("#username").val().indexOf("@") === -1) {
document.querySelector('.emailError').style.display = 'block';
return;
}
else if ($("#username").val().indexOf("@") !== -1) {
document.querySelector('.emailError').style.display = 'none';
}
end
disableFields();
document.forms[0].submit();
return false;
} else {
return true;
}
}
<input id="username" name="pf.username" type="text" class="form-control
card-input" value="$username" autocorrect="off" autocapitalize="off" onKeyPress="clearErrors();return postOnReturn(event)" autofocus>