MediaWiki:Common.js: Difference between revisions

Content deleted Content added
Undo revision 28070 by Pcoombe (talk)
use jquery, and allow special codes (arrow keys, backspace) through for Firefox
Line 297:
// Block typing symbols in input field, otherwise Safari allows them and then chokes
// https://phabricator.wikimedia.org/T118741
document.getElementById$('#input_amount_other_box').onkeypress =on('keypress', function(e) {
// Allow special keys in Firefox
if ((e.code == 'ArrowLeft') || (e.code == 'ArrowRight') ||
(e.code == 'ArrowUp') || (e.code == 'ArrowDown') ||
(e.code == 'Delete') || (e.code == 'Backspace')) {
return;
}
var chr = String.fromCharCode(e.which);
if ("0123456789., ".indexOf(chr) === -1) {
return false;
}
});
 
// Disable submitting form with Enter key