How do I make the name, subject and message fields required?
Also, Is there a way in EE to require that the email address be submitted a second time and verified?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
June 24, 2011 6:07pm
Subscribe [2]#1 / Jun 24, 2011 6:07pm
How do I make the name, subject and message fields required?
Also, Is there a way in EE to require that the email address be submitted a second time and verified?
#2 / Jun 27, 2011 1:45am
Stoelting,
Are you using FreeForm from Solspace or the standard Email Contact Form native to EE?
If it is the native EE functionality then you can read about required fields at the following link
http://ellislab.com/expressionengine/user-guide/modules/email/contact_form.html#form_required
If it is solspace you can find out more information by reading the following
http://www.solspace.com/docs/detail/freeform_form/#required
I hope this helps!
#3 / Jul 17, 2011 11:49am
Still not getting it. The EE documentation gives the example:
<textarea name="required" rows="5" cols="40" readonly="readonly"></textarea>I want to require that the user enter the subject. So in a basic form with user email, subject and message fields, I tried (separately):
{exp:email:contact_form user_recipients="false" required="subject"
recipients="[email protected]" charset="utf-8" return="{homepage}|Home Page" redirect="8"}
<label for="subject">Subject:</label> <input type="text" id="subject" name="required[]" size="60" />
and
<label for="subject">Subject:</label>
<input type="text" id="subject" name="required" size="60" />
{/exp:email:contact_form}Both of these allowed the email to be sent with an empty subject field.
What am I doing wrong?
#4 / Jul 17, 2011 3:31pm
Hi, Stoelting -
The required stuff in the EE contact form is a bit different than form validation, which I think is what you’re actually asking for. In that case, you’d need to use your own JS to do that field validation to achieve the results that you want.
Did you want me to move this down to Community Help for more assistance implementing a solution?
#5 / Jul 17, 2011 4:26pm
I’m not asking for validation of an email address or to compare 2 email address entries to ensure that they are the same. I just want to make sure that the user can’t submit a post if there is no content in the subject field.
The basic form will not allow a submission if there is no content in the message field. I’m trying to get the same result if there is no content in the subject field. Does this require JS?
#6 / Jul 17, 2011 4:37pm
want to make sure that the user can’t submit a post if there is no content in the subject field.
Testing for a blank input is still validation.
But I think I see it. You have:
name="required"Try
name="required[]"to include it in the required array.
Does that help? Sorry I missed that the first time.
#7 / Jul 17, 2011 5:11pm
I tried with and without the [], but neither worked. Here’s my latest attempt:
{exp:email:contact_form user_recipients="false" recipients="[email protected]" charset="utf-8" return="{homepage}|Home Page" redirect="8"}
<label for="from">Your Email:</label>
<input type="text" id="from" name="from" size="40" maxlength="35" /></p>
<label for="subject">Subject:</label>
<input type="text" id="subject" name="required[]" size="60" /></p>
<label for="message">Your Message or Question:</label>
<textarea id="message" class="textarea" name="message" rows="18" cols="60"></textarea>
<input name="submit" class="submit_button" type='submit' value='Send Email' /></p>
{/exp:email:contact_form}It still submits an email without a subject.
#8 / Jul 17, 2011 8:20pm
Hi, Stoelting,
Alright, I had to remind myself about this as it has been awhile. The required[] has nothing to do with validation, so as I did say earlier, you do need to use Javascript for this.
See this comment. The required[] attributes means that the information will be included at the top of each email.
I’d recommend using one of the many jQuery form validators out there to achieve your goal in this case.