#!/usr/bin/perl # use CGI::Ex::Validate; my $val_hash = { 'group order' => [qw(date fname lname email email2 telephone choice comments)], date => { name => 'Date(s) of Workshop *', # field is not optional in this case required => 1, match => 'm|^\d\d\d\d/\d\d/\d\d$|', match_error => 'Please enter date in YYYY/MM/DD format', custom_js => "function (args) { var t = new Date(); var y = t.getYear()+1900; var m = t.getMonth() + 1; var d = t.getDate();) if (m < 10) m = '0'+m; if (d < 10) d = '0'+d; (args.value > ''+y+'/'+m+'/'+d) ? 1 : 0; }", custom_js_error => 'The date was not greater than today.', }, fname => { name => 'First name *', required => 1, min_len => 2, max_len => 50, }, lname => { name => 'Last name *', required => 1, min_len => 2, max_len => 75, }, email => { name => 'Email *', required => 1, max_len => 100, type => 'email', type_error => '$name must be a valid email address.', }, email2 => { validate_if => 'email was_valid', vif_disable => 1, name => 'Verify email *', required => 1, equals => 'email', }, telephone => { name => 'Telephone *', required => 1, max_values => 1, max_len => 14, }, # # attempt to create radio-buttons. # 'group order'=>[qw(yes no)], 'yes' =>{ max_in_set=> '1 of yes, no', }, 'no'=>{ max_in_set => '2 of yes, no', }, comments => { name => 'Additional Info', max_len => 3000, }, }; # my $vob = CGI::Ex::Validate->new; open( OUT, ">form2.html" ) or die "can't open out $!"; my $js_uri_path="/CGI-Ex-2.38/lib/CGI/Ex/validate.js"; my $form_name = "the_form"; # name of the form to attach javascript to my $form = $vob->generate_form( $val_hash, { form_name => $form_name, # will use a random name if not passed js_uri_path => $js_uri_path, } ); print OUT $form;