Setting maxlength in Firefox & Opera

Setting maxlength in Firefox & Opera

Hi guys,

Setting maxlength attribute of input[type=text] or input[type=password] does not work as expected.
In Firefox and Opera if maxlength is not set the field.attr('maxlength') == -1. But if I try to set field.attr('maxlength', -1) it is being set to 0 instead.
Please find attached example.
What is the best way to proceed with it?

UPDATE:
Attaching files does not work for me so here is the link to it

Michal