hello monks,

I found node Re: Form validation - server-side (Dancer) and client-side (javascript) and I'm trying to use the mentioned module CGI::Ex::Validate. I'm trying to get it to work and the code below results in a HTML-Form included with Javascript for client-side. Happy with that, except that I can't seem to find out how to add code that gives me a simple set of radio-buttons. Is there anyone who has experience with that and cares to share information on that?

Thanks, Gert
#!/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;

In reply to validation built form with cgi::ex::validate that has radio buttons by GertMT

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.