Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 10-08-2008 10:07:48

cornweb
Member
From: Plymouth
Registered: 07-07-2004
Posts: 68
Website

Form validation for dynamic forms

Hello

Can anyone help me with a script to check form fields on dynamic forms?

I have tried several different scripts (including the one below) but wthhout success.

The form below should check for a valid email address, it was posted on this site sometime ago by Rachael Stevens.

I dont understand how this works or what the museum but does at the end!

from ste_form.pl
-----------------------------------------------------------------------------------------------
##########
########## Send the message.
##########

$emailfrom_value = $q->param($dynform_emailfrom);

if ($emailfrom_value !~ /^([A-Z0-9]+[._]?){1,}[A-Z0-9-]+\@(([A-Z0-9]+[-]?){1,}[A-Z0-9]+\.){1,}([A-Z]{2,4}|museum)$/i)  {

$print_message_id = "45";

$fd_pg = "ste_form";

} else {

&vars_mailer($to,$emailfrom_value,$subject,$mail_display);

$fd_pg = "ste_confirm";

} #### End of if statement1.
} ######### End of if statement2.
} ######### End of if statement.

----------------------------------------------------------------------------------------------

Thank you.
Mark Bowles

Offline

 

#2 10-08-2008 10:14:47

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Form validation for dynamic forms

This bit of code is designed to check the email address provided and send the user back with an error message if the email address is not valid.  The 'museum' bit is just to allow for a valid (but very rare) top level domain of .museum.  It will be applied as part of the ste_form.pl PERL script.  What problem are you having exactly?


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#3 10-08-2008 11:02:38

cornweb
Member
From: Plymouth
Registered: 07-07-2004
Posts: 68
Website

Re: Form validation for dynamic forms

Hello Rachael

The problem i have at the moment is that the dynamic form I created in the cart is getting too much SPAM as any value entered on the form is accepted.

In its present form, the script does not appear to check the email field on the form, it does not accept any email address i put in and displays error message 45.

I would also like to check each field on the form is correct by checking against alpha/numeric and numeric characters entered in the fields.

I think this is going to be a long job but if I could use the code for all forms on the site it will be very worthwhile.

Mark Bowles

Offline

 

#4 10-08-2008 12:02:36

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Form validation for dynamic forms

Seems like a reasonable enough bit of code.  The regex does seem to identify valid email addresses according to my tests (looks like one I've used, actually) and the logic is sound.  Perhaps the code is not in exactly the right place?  You could post the contents of ste_form_proc and I could take a look if you want.  But for the more involved checks you want to run, it might not be a bad idea to talk to Stephen at cartmod.com about some bespoke work.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#5 10-08-2008 16:53:46

cornweb
Member
From: Plymouth
Registered: 07-07-2004
Posts: 68
Website

Re: Form validation for dynamic forms

Hello Rachael

As PERL programming is not my strongest subject, I have created a new form using HTML inside a HTML user page and added some Javascript form checking in a separate file. This is working fine but I am not sure how to apply it to the 'built' in forms within the cart. Any ideas?

Offline

 

#6 10-08-2008 17:50:13

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Form validation for dynamic forms

Which forms did you have in mind?  That sort of thing is easy enough to do on the contact form, for example - just put the javascript right in the page which you can edit through the system pages menu.  Checkout forms are a bit tougher... you have to modify the checkout elements.  Dynamic forms I'm really not sure about, since I have never actually used one on my site, but I imagine it would be done through either ste_form.pl, an element, or possibly both.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#7 10-09-2008 06:33:51

cornweb
Member
From: Plymouth
Registered: 07-07-2004
Posts: 68
Website

Re: Form validation for dynamic forms

Hello Rachael

My client has decided to remove the page in question as they are still getting too much SPAM from the dynamic page. None of the other pages get any (or very little) SPAM which is strange...

Thanks for your advice.

Mark Bowles

Offline

 

Board footer