[-
use Embperl::Form::Validate ;
$epf = Embperl::Form::Validate -> new (
[
[
-key => 'name',
-name => 'Name',
required => 1,
length_min => 4,
],
[
-key => 'id',
-name => 'Id',
-type => 'Number',
gt => 0,
lt => 10,
],
[
-key => 'email',
-msg => 'This is not a valid E-Mail address',
must_contain_one_of => '@.',
matches_regex => '..+@..+\\...+',
length_min => 8,
],
[
-key => 'msg',
-name => 'Message',
emptyok => 1,
length_min => 10,
]
]) ;
if ($fdat{check})
{
$errors = $epf -> validate_messages ;
}
-]
Embperl Example - Input Form Validation
This example simply validates the form input when you hit submit.
If your input is correct, the form is redisplay with your input,
otherwise the error message is shown. If you turn off JavaScript
the validation is still done one the server-side. Any validation
for which no JavaScript validation is defined (like regex matches),
only the server-side validation is performed.
[$if @$errors $]
Please correct the following errors
[$foreach $e (@$errors)$]
[+ $e +]
[$endforeach$]
[$else$]
Please enter your data
[$endif$]
Embperl (c) 1997-2005 G.Richter / ecos gmbh www.ecos.de