MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
use jquery, and allow special codes (arrow keys, backspace) through for Firefox
sigh, lets try vanilla js again
Line 296: Line 296:


// Block typing symbols in input field, otherwise Safari allows them and then chokes
// Block typing symbols in input field, otherwise Safari allows them and then chokes
// https://phabricator.wikimedia.org/T118741
// https://phabricator.wikimedia.org/T118741, https://phabricator.wikimedia.org/T173431
$('#input_amount_other_box').on('keypress', function(e) {
var amountOtherInput = document.getElementById('input_amount_other_box');
// Allow special keys in Firefox
if ( amountOtherInput ) {
if ((e.code == 'ArrowLeft') || (e.code == 'ArrowRight') ||
(e.code == 'ArrowUp') || (e.code == 'ArrowDown') ||
amountOtherInput.onkeypress = function(e) {
(e.code == 'Delete') || (e.code == 'Backspace')) {
// Allow special keys in Firefox
return;
if ((e.code == 'ArrowLeft') || (e.code == 'ArrowRight') ||
(e.code == 'ArrowUp') || (e.code == 'ArrowDown') ||
}
var chr = String.fromCharCode(e.which);
(e.code == 'Delete') || (e.code == 'Backspace')) {
if ("0123456789., ".indexOf(chr) === -1) {
return;
return false;
}
}
var chr = String.fromCharCode(e.which);
if ("0123456789., ".indexOf(chr) === -1) {
});
return false;
}
};
}


// Disable submitting form with Enter key
// Disable submitting form with Enter key