Skip Menu |

This queue is for tickets about the CGI-FormBuilder CPAN distribution.

Report information
The Basics
Id: 2851
Status: resolved
Priority: 0/
Queue: CGI-FormBuilder

People
Owner: Nobody in particular
Requestors: Matthew.Maguire [...] alcatel.com.au
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.07
Fixed in: (no value)



Subject: Can't use literal javascript validation checks for required fields
When using a literal javascript string to validate a required form field, the literal javascript code supplied in not being included in the validation() function in the form's javascript header. For example, my $form = CGI::FormBuilder->new( method => 'POST', fields => [qw/password confirm_password/], required => 'ALL', validate => { confirm_password => { javascript => '== form.elements[\'password\'].value', perl => 'eq $form->field("password")' } } ); This will not generate javascript validation code to check that the password and confirm_password fields are the same. I have attached a patch for CGI-FormBuilder-2.07 which I believe should correct this problem. My system details, FWIW: CGI-FormBuilder-2.07 This is perl, version 5.005_03 built for sun4-solaris SunOS xxxxxx 5.7 Generic_106541-22 sun4u sparc SUNW,Ultra-4
diff -rc CGI-FormBuilder-2.07/FormBuilder.pm CGI-FormBuilder-2.07a/FormBuilder.pm *** CGI-FormBuilder-2.07/FormBuilder.pm Sat Oct 5 03:42:27 2002 --- CGI-FormBuilder-2.07a/FormBuilder.pm Wed Jun 25 18:06:08 2003 *************** *** 1061,1067 **** # can you figure out how this piece of Perl works? ha ha ha ha .... $jsfunc .= "$in if ($nn ($jsfield != '" . join("' && $jsfield != '", @{$pattern}) . "') ) {\n"; ! } elsif ($pattern eq 'VALUE' || $need{$field}) { # Not null $jsfunc .= qq($in if ($nn ((! $jsfield && $jsfield != 0) || $jsfield === "")) {\n); } else { --- 1061,1067 ---- # can you figure out how this piece of Perl works? ha ha ha ha .... $jsfunc .= "$in if ($nn ($jsfield != '" . join("' && $jsfield != '", @{$pattern}) . "') ) {\n"; ! } elsif ($pattern eq 'VALUE' && $need{$field}) { # Not null $jsfunc .= qq($in if ($nn ((! $jsfield && $jsfield != 0) || $jsfield === "")) {\n); } else {