<%args> $name => undef $email => undef $comments => undef $company => undef $company_website => undef <%once> use Email::Valid; Readonly my $info_email => 'info@dewoollery.co.uk'; Readonly my %default => ( name => '', email => '', company => '', company_website => '', comments => '' ); my %errors = (); <%init> # Check the submission details %errors = (); if( $ARGS{send} ) { push( @{$errors{'name'}}, "Please provide a contact name" ) unless( $name and $name ne $default{name} ); push( @{$errors{'comments'}}, "Please provide a comment or two" ) unless( $comments and $comments ne $default{comments} ); push( @{$errors{'email'}}, "Please provide an email address" ) unless( $email and $email ne $default{email} ); push( @{$errors{'email'}}, "The email address does not appear to be valid" ) if( $email and $email ne $default{email} and ! Email::Valid->address( $email ) ); # Send the email through unless( keys %errors ) { MIME::Lite->new( From => "$name <$email>", To => $info_email, Subject => "Webpage Contact", Data => qq( Company: $company Company Website: $company_website Comments: $comments ) )->send; } } % if( $ARGS{send} and ! keys %errors ) {

Thank You

Thank you for your interest in Dewoollery. We do our best to read, and respond to all messages in good time. Time constraints may result in a slight delay in this response, please accept our apologies if this is the case.

% } else { <& SELF:displayErrors, errors => \%errors &>
Contact Us
% } <%filter> foreach my $field ( keys %errors ) { s{(id="_$field")}{$1 class="inerror"}; }