-
-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from daviddarnes/enhance-form-include
#103 Enhance form include
- Loading branch information
Showing
3 changed files
with
68 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,53 @@ | ||
<div class="form form--contact"> | ||
<form class="contact-form" action="" method="POST"> | ||
<label class="label" for="name">Name: <span class="required">*</span></label> | ||
<input class="input" id="name" type="text" name="name" value="" placeholder="Your Name" required="required" /> | ||
{% if include.name %} | ||
{% assign name = include.name %} | ||
{% else %} | ||
{% assign name = "Contact" %} | ||
{% endif %} | ||
|
||
<label class="label" for="_replyto">Email Address: <span class="required">*</span></label> | ||
<input class="input" id="_replyto" type="email" name="_replyto" value="" placeholder="[email protected]" required="required" /> | ||
{% assign name_id = name | downcase | replace: " ", "-" %} | ||
|
||
<label class="label" for="message">Message: <span class="required">*</span></label> | ||
<textarea class="textarea" id="message" name="message" placeholder="Your message..." required="required"></textarea> | ||
{% if include.thanks_url %} | ||
{% assign thanks_url = include.thanks_url %} | ||
{% else %} | ||
{% assign thanks_url = "/thanks/" %} | ||
{% endif %} | ||
|
||
<form class="form form--{{ name_id }}" method="post" name="{{ name }}" action="{{ thanks_url }}" | ||
{% if include.netlify_form %} | ||
netlify-honeypot="bot-field" | ||
netlify | ||
{% endif %} | ||
> | ||
<fieldset class="fieldset form__fieldset"> | ||
<legend class="legend form__legend">{{ name }}</legend> | ||
<label class="label" for="name--{{ name_id }}">Name: <span class="required">*</span></label> | ||
<input class="input" id="name--{{ name_id }}" type="text" name="name" value="" placeholder="Your Name" required="required" /> | ||
|
||
<label class="label" for="email--{{ name_id }}">Email Address: <span class="required">*</span></label> | ||
<input class="input" id="email--{{ name_id }}" type="email" name="email" value="" placeholder="[email protected]" required="required" /> | ||
|
||
<label class="label" for="message--{{ name_id }}">Message: <span class="required">*</span></label> | ||
<textarea class="textarea" id="message--{{ name_id }}" name="message" placeholder="Your message..." required="required"></textarea> | ||
|
||
<input class="button" type="submit" value="Send message" /> | ||
<br/> | ||
<small class="small"><span class="required">*</span> indicates a required field</small> | ||
|
||
<input type="text" name="_gotcha" style="display:none"> | ||
<input type="hidden" name="_subject" value="Message from {{ site.name }} website"> | ||
<input type="hidden" name="_next" value="/thanks/" /> | ||
</form> | ||
</div> | ||
<script> | ||
var email = "{{ site.email | split: "" | reverse | join: "" }}"; | ||
var unraveledEmail = email.split("").reverse().join(""); | ||
var form = document.querySelector(".contact-form"); | ||
form.setAttribute("action", "https://formspree.io/" + unraveledEmail); | ||
</script> | ||
<noscript>Please enable JavaScript to use the form.</noscript> | ||
{% if include.netlify_form %} | ||
<label style="display:none">Don’t fill this out if you’re human: <input name="bot-field" /></label> | ||
{% else %} | ||
<input type="text" name="_gotcha" style="display:none"> | ||
<input type="hidden" name="_subject" value="{{ site.title }} submission from {{ name }}"> | ||
<input type="hidden" name="_next" value="{{ thanks_url }}" /> | ||
{% endif %} | ||
</fieldset> | ||
</form> | ||
{% unless include.netlify_form %} | ||
<script> | ||
var email = "{{ site.email | split: "" | reverse | join: "" }}"; | ||
var unraveledEmail = email.split("").reverse().join(""); | ||
var form = document.querySelector(".form--{{ name_id }}"); | ||
form.setAttribute("action", "https://formspree.io/" + unraveledEmail); | ||
</script> | ||
<noscript>Please enable JavaScript to use the form.</noscript> | ||
{% endunless %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters