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.

Required Fields in Contact Form

April 13, 2011 3:59pm

Subscribe [3]
  • #1 / Apr 13, 2011 3:59pm

    tsfexhibit

    22 posts

    Hello,

    I would like to make one or more of the fields in a form not required, while making other fields required.

    http://www.tsfexhibit.com/site/contactus

    At this point the sender’s email and the message are required. I’d like to change that to name and email only but leave the other fields there as an option.

    When I put in the variable “required” it has no effect.

    {exp:email:contact_form user_recipients="false" recipients="[email protected],[email protected]" charset="utf-8"}
    <input type="hidden" name="subject" size="40" value="TSF Website Contact Form" />
    <label name="required[]"><span class="required">*</span> Name:</label>
    
    <input name="name" type="text" id="name" class="formInput" />
    
    
    <label name="required[]"><span class="required">*</span> E-mail:</label>
    
    <input name="from" type="text" id="email" class="formInput" />
    
    
    <label>Company Name:</label>
    
    <input name="message[]" type="text" id="company" class="formInput" />
    
    
    <label>Website:</label>
    
    <input name="message[]" type="text" id="website" class="formInput" />
    
    
    <label>Phone:</label>
    
    <input name="message[]" type="text" id="phone" class="formInput" />
    
    
    *(required)
    <label>How Can We Help You:</label>
    
    
    
    <textarea name="message[]" cols="35" rows="7" id="helpme"></textarea>
    
    
    
    
    <input type="image" name="submit" src="{path='site_index'}siteimages/submit.png" value="SUBMIT" />
    
    {/exp:email:contact_form}
  • #2 / Apr 13, 2011 5:59pm

    dencreative

    20 posts

    Hi,

    Try adding the required attribute to the <input> rather than the <label>

  • #3 / Apr 13, 2011 6:29pm

    tsfexhibit

    22 posts

    I tried that but did not work. - It ignored it completely.

  • #4 / Apr 14, 2011 7:36pm

    smartpill

    456 posts

    Your best bet is using Freeform instead.

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

ExpressionEngine News!

#eecms, #events, #releases