Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

field_filters not working

by bar10der (Beadle)
on May 12, 2004 at 13:05 UTC ( #352715=perlquestion: print w/replies, xml ) Need Help??

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

I am writing a form validation code using validatorRM. My script is working fine except it is not checking for the 'digit only' fields.

here is code

my ($results,$err_page) = $self->check_rm('sam',{ required => [ qw/ systemspcust smcsystems syswithsrsnetv3 repp +cust contupdatedate p3target p3implemented srsnetconn2 cstinstall avgori /], dependencies => {"osc" => {Yes => [ qw( oscperc ) ],}, "mrepto +cust" => {Yes => [ qw( marialoc ) ],}, "p3tocust" =>{Yes => [ qw( updatedate ) ],}, }, field_filters => { smcsystems => ['digit'], systemspcust => [' +digit'],}, filters => ['trim'], msgs =>{ any_errors => 'err__', prefix=>'err_' }, }); return $err_page if $err_page;

I know field_filters part is failing but don't know what mistake I am making. Can someone help please?

Replies are listed 'Best First'.
Re: field_filters not working
by Thelonius (Priest) on May 12, 2004 at 13:33 UTC
    It would be helpful if you included some context, as you did in your last question: "Hi, I am trying to use CGI:Application's validateRM function to validate my forms."

    It would also be helpful for us if you would tell us how the field_filters part is failing.

      Hi Thelonius,

      I thought its obvious that I am using CGI:Application's validateRM function to validate my form.

      As far as how field_filters is failing is concerned, when I am submitting form with non-numeric data in those fields included in filed_filters, the form does not report back error but instead form is submitted. What I am expecting is that formValidator reports error as is does when required fields are left blank or when dependencies are broken.

        The 'digit' filter is supposed to remove non-digit characters from the field, not give an error.

        I think what you want is a constraint.

Re: field_filters not working
by bar10der (Beadle) on May 12, 2004 at 15:41 UTC
    Hi, I did write a constraint but looks like I am struck a bit. Here is the code -

    constraints => { smcsystems => qr/^\d+$/,}

    But above is accepting any data - numeric and non-numeric. However if i change code to ->

    constraints => { smcsystems => qr/^\d{3}$/,}

    It does validate data but then I have to enter 3 digits(that is the max length allowed in my form field). Now I am not sure how I can write reg-ex so that it accepts any number of digits but no alpha chars.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2021-09-17 04:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?