Data::FormValidator::ErrMsgs::JavaScript - Let JavaScript handle DFV error presentation.
use Data::FormValidator::ErrMsgs::JavaScript (qw/&dfv_js_error_msgs/); # In a DFV profile: msgs => \&dfv_js_error_msgs,
Now your error messages will come out like this:
<script type="text/javascript">dfv_error_msg('field_name');</script>
See SYNOPSIS above for syntax.
It's up to you define the dfv_error_msg function in JavaScript to do something interesting.
dfv_error_msg
This function respects the following msgs configuration directives, which are documented more in Data::FormValidator:
msgs
prefix any_errors
Of course, these can't be set directly in the profile anymore because the callback is there. They can still be set through the defaults system documented in Data::FormValidator.
More detail could be passed through to the JavaScript function about the failure. This may change in the future, perhaps in an incompatible way.
It is not currently possible to use a format string other than the one provided.
Workarounds included sending a patch or using this routine as the basis for your own.
That workaround might look like this:
msgs => dfv_js_error_msgs({ format => 'foo: %'; });
A closure could then be created which passing in the arguments you want.
If you like this extension to Data::FormValidator, give me some feedback on the Data::FormValidator list and we'll work out a stable interface.
http://lists.sourceforge.net/lists/listinfo/cascade-dataform
Mark Stosberg, <mark at summersault.com>
<mark at summersault.com>
Please report any bugs or feature requests to bug-data-formvalidator-errmsgs-javascript at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-FormValidator-ErrMsgs-JavaScript. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-data-formvalidator-errmsgs-javascript at rt.cpan.org
Data::FormValidator http://search.cpan.org/dist/Data-FormValidator-ErrMsgs-JavaScript
Copyright 2005 Mark Stosberg, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Data::FormValidator::ErrMsgs::JavaScript, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::FormValidator::ErrMsgs::JavaScript
CPAN shell
perl -MCPAN -e shell install Data::FormValidator::ErrMsgs::JavaScript
For more information on module installation, please visit the detailed CPAN module installation guide.