Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Mandatory Fields

by Anonymous Monk
on Jun 05, 2003 at 21:57 UTC ( [id://263527]=perlquestion: print w/replies, xml ) Need Help??

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

I currently have the following for some mandatory fields:

$Mandatory_Fields="*Customer Name*Customer Email*Phone Number*Payment +Method*BillingAddressLine1*BillingCity*BillingPostCode*CardStartDate* +CardIssueNo*CardSecurityCode";
Idealy I would like to make the CardStartDate, CardIssueNo and CardSecurityCode only mandatory if credit card as a payment method is selected. Is there anything like an immediate if I could place in there to only make these mandatory if a radio button is true? I hope I have explained this clearly. Thanks as always. Simon

Replies are listed 'Best First'.
Re: Mandatory Fields
by ehdonhon (Curate) on Jun 05, 2003 at 22:25 UTC

    Make it a bit more readable while you're at it.

    $Mandatory_Fields= '*' . join( '*', 'Customer Name', 'Customer Email', 'Phone Number', 'Payment Method', 'BillingAddressLine1', 'BillingCity', 'BillingPostCode', param( 'Payment Method' ) eq 'Credit Card' ? qw( CardStartDate CardIssueNo CardSecurityCode ) : () );

    Update: I see that Anonymous wants a '*' before each entry including the first one, not just as a delimeter.
      Hi, I have just tried:
      $Mandatory_Fields= '*' . join( '*', 'Customer Name', 'Customer Email', 'Phone Number', 'Payment Method', 'BillingAddressLine1', 'BillingCity', 'BillingPostCode', param( 'payMethods' ) eq 'Credit Card' ? qw( CardStartDate CardIssueNo CardSecurityCode ) : () );
      But I am getting an internal server error when trying it out. Any ideas please?

        Try running:

        perl -c scriptname

        Internal server errors are usually the result of your code not compiling. If that is the case, running perl -c will give you a more helpful error message.

Re: Mandatory Fields
by silent11 (Vicar) on Jun 05, 2003 at 22:04 UTC
    using CGI.pm you could.
    if ( $cgi->param("radiobutton") eq "true" ) { $Mandatory_Fields = "this and that and that..."; }else { $Mandatory_Fields = "this and that..."; }


    -silent11

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-20 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found