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.
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
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?
Offline
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
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.
Offline
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
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.
Offline
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