To simplify things here's a jQuery plugin that can achieve this goal : https://github.com/haggen/readonly
Replace .attr('readonly', 'readonly')
with .readonly()
instead.
That's it.
For example, change from $(".someClass").attr('readonly', 'readonly');
to $(".someClass").readonly();
.