jQuery Masked Input – Is it possible to recover the mask attached to the field?

Posted on

Question :

I’m using jQuery Masked Input Plugin with jQuery Validation Plugin . When a form field loses focus, the validation plugin shows a message, but this is not happening with the fields that are have masks, perhaps because the blur event happens and verifies that the field is not empty, actually the field is filled with the mask.

So I overwritten the required method of the validation plugin to check the masks as well, but I have to check the mask. As I have several masks I can not hard code the mask, I would have to call a method in the plugin that returns me the mask bound to the field. I did not find the plugin documentation and no one with my problem.

Does anyone know if there is a method that returns the mask bound to the field?


Answer :

Looking at the source code looks like the value passed by parameter to the mask function is not stored anywhere.

What you can do by inspecting the code is to see if the field has a mask accessing the attribute data called rawMaskFn :


In my experience, this plugin is very limited in functionality.


Leave a Reply

Your email address will not be published. Required fields are marked *