Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Form validation using ValidateRM

by bar10der (Beadle)
on May 11, 2004 at 14:07 UTC ( [id://352445]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://352445]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-18 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found