client_side_validations icon indicating copy to clipboard operation
client_side_validations copied to clipboard

adding compatibility with masked-input plugin

Open drsquidop opened this issue 15 years ago • 4 comments

Client side validations is a great gem.

When using this with the masked-input-plugin (http://digitalbush.com/projects/masked-input-plugin), it looks like fields with masked input do not call the validation on blur.

Any idea what/how to hook to do the validation? line 243 of the jquery.maskedinput-1.3.js file reads as follows:

                .bind("blur.mask", function() {
                    checkVal();
                    if (input.val() != focusText) {
                        input.change();                         
                    }
                    //CAN WE HOOK HERE, tried the following but didn't work
                    //input.change().focusout();
                })

that code is getting called when tabbing out of the field

drsquidop avatar Oct 03 '11 02:10 drsquidop

I really don't know, I'm not familiar with this library.

bcardarella avatar Oct 08 '11 08:10 bcardarella

Do you know in general what the strategy is to re-hook client side validations if another library is binding to the onblur? Do you think the approach above is on the right track?
Thanks

drsquidop avatar Oct 22 '11 20:10 drsquidop

Something that worked for me was to rebind the focusout of client_side_validations after binding the masked-input. Something like (coffeScript):

settings = window[$('form').attr('id')] $('.phone').mask('(99) 9999-9999').focusout( -> $(this).isValid(settings.validators))

barbolo avatar Nov 05 '11 02:11 barbolo

Thanks Rafael!

Sent from my iPhone

On Nov 4, 2011, at 7:15 PM, Rafael [email protected] wrote:

Something that worked for me was to rebind the focusout of client_side_validations after binding the masked-input. Something like (coffeScript):

settings = window[$('form').attr('id')] $('.phone').mask('(99) 9999-9999').focusout( -> $(this).isValid(settings.validators))


Reply to this email directly or view it on GitHub: https://github.com/bcardarella/client_side_validations/issues/194#issuecomment-2638508

drsquidop avatar Nov 07 '11 01:11 drsquidop