Basic Form Questions

6 views
Skip to first unread message

Captain Nordic

unread,
Sep 10, 2008, 1:42:14 PM9/10/08
to JustHumans
Dear Anders,

I've been using a PHP Mail Script for years (MMEX) and it's always
worked great, but in the past year I've been getting so much form spam
I've been looking for alternatives. I don't have a lot of scripting
knowledge, so the MMEX form was very satisfactory. But in the past few
months I've been searching for an option for form verification
(Captcha, Kmita Mail, etc.), but they've all been above my head in
using. Your service is GREAT (so far). I love the simplicity and ease.
So far it's working really really well.

I had the MMEX script set up with some parameters that I would like to
replicate, though.
My questions:
- Can I send the submission form to multiple email addresses? How?
- Can I make some of the fields on the form required? (for instance,
they have to list their name and email, but can leave some of the
fields blank if they want.)
- Can I require a particular format for some of the fields? (phone
numbers in xxx-xxx-xxxx for example)
- Is there a way to automatically send a confirmation email to the
subscriber as well?

It's possible that these questions are basic form set-up questions,
but since I've never used CGI I never figured out how to do this. If
there is a simple primer on setting these up, I'd love to be directed
to it.

Here is the link to the form I set up:
http://www.xcjuniorolympics2009.org/forms/volunteerform-jh.html

Thanks AGAIN for setting this up for remedial users such as myself.
It's a great service to the web community.

Mark Nadell

Anders Brownworth

unread,
Sep 10, 2008, 2:14:27 PM9/10/08
to justh...@googlegroups.com
Hi Mark,

Thanks for the positive comments. I'm glad the service is wrking out for you.

You can't send to more than one email address at the moment. I'm considering making this an option because a number of people have asked for it. I had assumed that people would rather enter a distribution address that sends copes to multiple people if they wanted that. This way email address management would be in the hands of the users and not constrained to what the JustHumans capabilities are. For example, it would be easier to add and subtract people from lists than to have your users come to you to ask you to change that in JustHumans. I could be wrong though as a number of people have asked.

You can make some of the fields in your form required although the check would not happen at JustHumans. The way you would do that is to use JavaScript to check the fields. How to do that is somewhat out of scope for JustHumans but you can trigger a check with the onSubmit property of the form as in the following example:

<script language="JavaScript">
<!--

function checkCommentsForm( f ) {
if ( f.comments.value.length == 0 ) {
f.comments.focus( );
alert( "Please enter a comment!" );
return( false );

}
return( true );

}

-->
</script>

<form method="post" onSubmit="return( checkCommentsForm( this ) )">
Comments:
<textarea name="comments"></textarea>
<script language="javascript" src="http://verify.justhumans.com/verification.js?k=a1b2c3"></script>
</form>

Granted, this is an overly simple example that I typed off the top of my head. Other sources are going to be better but this should get you started.

You would do the same for requiring a particular format in a response. For example, I wrote a little routine called "onlyContains" which can be called from the checkCommentsForm script above. For example, if I only wanted numbers, I could rewrite the above code to this:

<script language="JavaScript">
<!--

function onlyContains( txt, validChars ) {
var goodChars = true;
var c;

for ( i = 0; i < txt.length && goodChars == true; i++ ) {
c = txt.charAt( i );
if ( validChars.indexOf( c ) == -1 ) {
goodChars = false;

}

}
return( goodChars );

}

function checkCommentsForm( f ) {
if ( f.comments.value.length == 0 ) {
f.comments.focus( );
alert( "Please only enter numbers!" );
return( false );

}
else {
if ( ! onlyContains( f.comments.value, "0123456789" ) ) {
f.comments.focus( );
alert( "Please only enter numbers!" );
return( false );

}

}
return( true );

}

-->
</script>

<form method="post" onSubmit="return( checkCommentsForm( this ) )">
Comments:
<textarea name="comments"></textarea>
<script language="javascript" src="http://verify.justhumans.com/verification.js?k=a1b2c3"></script>
</form>

Granted, it is a little rediculous to only want numbers in a comments box but the example would work for phone number fields as well. There are a number of other ways to do this though so do a few Google searches around the terms "javascript form check".

Sending a confirmation email to the submitter of the form is possible through the "Re-post URL". The idea is once a successful form post happens, JustHumans posts those form fields to a CGI on your site. That CGI could send an email to the address posted. You don't want JustHumans sending the email because then the email will be coming from JustHumans. (not your site) Of course this requires that you have a CGI script on your website which is capable of sending emails when they get something.

Best,

Anders
--
-Anders
-----------------------------------------------------------
Anders Brownworth
http://www.anders.com/
ande...@gmail.com
Reply all
Reply to author
Forward
0 new messages