Re: [cgiapp] Data.FormValidator.js

2009-01-26 Thread Lyle

Joshua,
 Have you managed to figure out a work around for:-

'constraints' = {
   'password1' = {
   'constraint' = check_passwords,
   'params' = [ qw( password1 password2 ) ],
 },
 },
 ...
 sub check_passwords {
   my ( $pw1, $pw2 ) = @_;
   if ( $pw1 eq $pw2 ) {
 return 1;
   } else {
 return 0;
   }
 }


I would have thought this is common enough to warrant a work around...

I couldn't see one in your examples.

Am I missing something?


Lyle

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] [Fwd: Re: ValidateRM not PP]

2009-01-26 Thread Michael Peters

Lyle wrote:


  + Javascript code which has HTML in strings (very common in DHTML apps)


Does the current parser pick that up? I don't think HTML::Parser 
executes any JavaScript.


No, I'm saying that your simple regex approach whould change the JS code on the page, which is *not* 
what people would want.



  + HTML comments?
  + targetting specific forms?

Dealing with HTML requires a parser. Anything else won't make people 
happy.


I see. But there isn't a Pure Perl parser available, and for those that 
really can't get HTML::Parser on their cheap shared hosting, isn't a 
regexp that works most/some of the time better than nothing?


If it were me, the answer would be no. A minor template change could break your application in 
mysterious ways. I'd rather not have an HTML::FillInForm replacement than one that works sometimes 
and not others.


--
Michael Peters
Plus Three, LP


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] [Fwd: Re: ValidateRM not PP]

2009-01-26 Thread Michael Peters

Lyle wrote:

I've looked for one, the only one I could find is HTML::TagParser but it 
isn't suitable as it can't be used to recreate the page. Also looking at 
the source it uses regexp.


Just looking at the source code briefly, it seems that it's using regexes as part of it's 
lexing/tokenizing, which is completely appropriate.


As much as the idea of writing a Pure Perl parser intrigues me, I don't 
have the time :( Especially as at this time I wouldn't actually be using 
it (my script is generating all the html input tags and parsing them 
into the html template).


Have you thought about maybe using an XML module? XML::SAX has a pure perl driver. Maybe if your 
HTML is XHTML it could work. Or if you want, you can probably use a libxml based module. It's 
extremely common (installed on most systems) and has an forgiving/HTML mode.


--
Michael Peters
Plus Three, LP


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] Form validation best practices

2009-01-26 Thread Terrence Brannon
On Sat, Jan 24, 2009 at 8:56 AM, Cosimo Streppone cos...@streppone.itwrote:

 Hi,

 any suggestions about the best practices, most used modules,
 cgi-app plugins for generic form validation?

 So far, I looked at:

  - Form::Processor
  - Data::FormValidator
  - FormValidator::Simple (and C::A::FV::S)



I had used Data::FormValidator with CGI::Prototype and was thoroughly happy
with it.

Since I'm now doing a project with cgiapp, I ripped down
C::A::P::DataFormValidator and and am pleased to death with it. It does so
much heavy lifting... it validates the form and then if there are errors, it
returns you to a certain page and you can get the errors _AND_ it fills in
the form using HTML::FillInForm.

One plugin, saved me tons of work! Thank you Mark Stosberg and the cgiapp
community!!!



-- 
Terrence Brannon
(818) 359-0893 [cell]

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] Data.FormValidator.js

2009-01-26 Thread Joshua Miller
Apologies if this has gone too far offtopic...


On Mon, Jan 26, 2009 at 6:40 AM, Lyle webmas...@cosmicperl.com wrote:
 Joshua,
  Have you managed to figure out a work around for:-

 'constraints' = {
   'password1' = {
   'constraint' = check_passwords,
   'params' = [ qw( password1 password2 ) ],
 },
 },
  ...
  sub check_passwords {
   my ( $pw1, $pw2 ) = @_;
   if ( $pw1 eq $pw2 ) {
 return 1;
   } else {
 return 0;
   }
  }


Currently, there is no easy, built-in way to do this.

Many times, I'll just leave that up to the backend to handle. Of
course, it is possible to tie it in on the frontend. Take the
check_and_report function from the file Data/FormValidator.js, and
update the end part of it something like this:

if (! results.success()) {
...leave this stuff
} else {
// This is where you'd add the password eq check
// assuming the profile already checked password1 and password2
// had some valid value
var password1 = results.getField(frmObj, 'password1');
var password2 = results.getField(frmObj, 'password2');
if ( password1[0] != password2[0] ) {
results.changeStyle(frmObj, 'password1', badColor);
results.changeStyle(frmObj, 'password2', badColor);
alert(There is a problem with your form.\n\nThe entered
passwords do not match.);
return false
} else {
return true;
}
}


I would like to see Data.FormValidator.js get support for including
things like that in the profile. While it would break the profiles
compatibility with Data::FormValidator.pm, a filter could be
implemented to let the profile be used on both of them. I'm not
totally sure how that would work out though. At least for myself, I
usually generate the javascript profile from a profile written in
perl, and that would make it difficult to include a javascript
function definition inline.

I'm open to suggestions and patches, but that conversation should
probably be moved offlist or to the forum on the Data.FormValidator.js
berlios page.

Thanks,
--
Josh I.

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####