ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Contact Form Error - Email Message is Required

October 30, 2007 1:35pm

Subscribe [1]
  • #1 / Oct 30, 2007 1:35pm

    Deron Sizemore

    1033 posts

    I’m getting an “email message is required” error message on my contact form. Here is the code I’m using:

    {exp:email:contact_form user_recipients="false" redirect="3"}
    
                    <select name="recipients" id="recipients">
                    <option selected="selected">-- Deliver To --</option>
                    <option value="<?php echo base64_encode('email'); ?>">Deron</option>
                    <option value="<?php echo base64_encode('email'); ?>">Steven</option>
                    <option value="<?php echo base64_encode('email'); ?>">Nathan</option>
                    </select>
        
                    <label for="name">Your Name:</label> <span class="requiredfield">(required)</span>
    
                    <input type="text" class="field" id="name" name="required[]" size="40" maxlength="40" value="" />
    
                    <label for="from">Your Email:</label> <span class="requiredfield">(required - never shared)</span>
    
                    <input type="text" class="field" id="from" name="required[]" size="40" maxlength="40" value="" />
    
                    <label for="subject">Subject:</label> <span class="requiredfield">(required)</span>
    
                    <input type="text" class="field" id="subject" name="required[]" size="40" value="" />
    
                    <label for="message">Message:</label> <span class="requiredfield">(required)</span>
    
                    <textarea id="message" class="field-message" name="message[]" rows="8" cols="60"></textarea>
        
                    <input class="submit" name="submit" type='submit' value='Submit Form' />
    
                    {/exp:email:contact_form}

    I’m sure it has something to do with the required fields “name” attribute, but I’m not sure what I’m doing wrong. I’ve followed the docs to what I think is accurate?

    Thanks

  • #2 / Oct 30, 2007 2:48pm

    Lisa Wess

    20502 posts

    Deron, if you use the code directly from the docs, does it work?

  • #3 / Oct 30, 2007 3:30pm

    Deron Sizemore

    1033 posts

    Hey Lisa,

    okay I made some changes and the contact form works now. But I’ve got a couple more questions now. 😊

    Here’s my code after the changes:

    {exp:email:contact_form user_recipients="false" charset="utf-8"}
    
                    <select name="recipients" id="recipients">
                    <option selected="selected">-- Deliver To --</option>
                    <option value="<?php echo base64_encode('email'); ?>">Deron</option>
                    <option value="<?php echo base64_encode('email'); ?>">Steven</option>
                    <option value="<?php echo base64_encode('email'); ?>">Nathan</option>
                    </select>
    
                    <label for="name">Your Name:</label> <span class="requiredfield">(required)</span>
    
                    <input type="text" id="name" name="required[]" size="40" maxlength="40" />
    
                    <label for="from">Your Email:</label> <span class="requiredfield">(required - never shared)</span>
    
                    <input type="text" id="from" name="from" size="40" maxlength="40" />
    
                    <label for="subject">Subject:</label> <span class="requiredfield">(required)</span>
    
                    <input type="text" id="subject" name="required[]" size="40" />
    
                    <label for="message">Message:</label> <span class="requiredfield">(required)</span>
    
                    <textarea id="message" name="message" rows="8" cols="60"></textarea>
    
                    <input name="submit" type='submit' value='Submit Form' />
    
                    {/exp:email:contact_form}


    1. I cannot get the “name” and “subject” fields to be required. I’ve set the name parameter on those two fields to “required[]” as the documentation says, but it still will send the email without those two fields filled in. What am I doing wrong there?

    2. Lets say that I try to submit a blank form. If I leave the “email” and “message” fields blank I get the default EE error message telling me what fields I need to fill in. The thing is, is that this error message does not tell me all of the fields that I’m missing at once. It only tells me one at a time. Like, I can leave the email and message field both blank and try to submit, and it will only tell me that I need the message field. If I then go back and fill in the message field and click submit it will then tell me that I need the email filed too. Seems like it would be easier to list all errors at once? Any way to do that?

  • #4 / Oct 30, 2007 3:39pm

    Lisa Wess

    20502 posts

    Deron, if you need to validate your fields, you’ll need to use an external solution, there are many javascript form validators out there.  I’m going to move this up to the how-to forum for you.

    Didn’t you write a tutorial on validating the contact forms? I thought you did!

  • #5 / Oct 30, 2007 3:49pm

    Deron Sizemore

    1033 posts

    Ok, I think I was just confused from the start here.

    I was looking at this link: http://expressionengine.com/docs/modules/email/contact_form.html#form_required

    I guess I thought that by “required” it was saying that you could validate the field so that if you mark the “name” field as required[], and the user didn’t enter in a name then it would tell you needed the name field.

    I think that I misunderstood what the docs is saying though with that.

    Yeah, I did write a tutorial on that and would love to be able to use it, but unfortunately for this site, I’m also using a jQuery bit to rotate an image and the javascript form validation conflicts with the jQuery stuff, so I can either use one or the other.

    I’d love to be able to use FreeForm for this contact form because it’s SUPER easy to validate the fields, but, I’ve been trying for a couple weeks now to figure out a way to insert the drop down select list:

    <select name="recipients" id="recipients">
                    <option selected="selected">-- Deliver To --</option>
                    <option value="<?php echo base64_encode('email'); ?>">Deron</option>
                    <option value="<?php echo base64_encode('email'); ?>">Steven</option>
                    <option value="<?php echo base64_encode('email'); ?>">Nathan</option>
                    </select>

    Into a form using FreeForm. No one seems to know how to do this. I’ve got like ten different departments that need to be emailed on this site and I don’t want to set up ten different contact forms with FreeForm, so the drop down select list is ideal. It works with the exp:contact_form, just not freeform. lol. Ah!! 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases