bar10der has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to use CGI:Application's validateRM function to validate my forms. I am able to write a rule for all the form fields for which input is required and here is the code

my ($results,$err_page) = $self->check_rm('sam',{ required => ['systemspcust','smcsystems'], optional => ['syswithsrsnetv3'], msgs=>{ any_errors => 'err__', prefix=>'err_' }, }); return $err_page if $err_page;

I am facing problem in two cases -

1. There is a field (eg bonus) which must be entered if user has selected 'Yes' option from a selection option ('Eligible').

2. How can I make sure that user enters only digits in certain field eg. bonusAmt ?

How can I do the above two?

Please help as I am writing my first validateRM script.

Replies are listed 'Best First'.
Re: Form validation using ValidateRM
by jdtoronto (Prior) on May 11, 2004 at 14:39 UTC
    1. There is a field (eg bonus) which must be entered if user has selected 'Yes' option from a selection option ('Eligible').

    Use a dependency group - see the module docs, using dependencies and dependency groups you can require a field to be filled in if a pre-requisite field is filled in, or if one of a group is filled in then all are required.

    Getting digits only:

    There is a Data::FormValidator::Filters module installed with the parent module. You can use a filer of ... digit!

    field_filters => { cc_no => "digit" },
    is an example form the docs for Data:FormValidator jdtoronto
      Thanks. It did work for me.