Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ERB version of my Sinatra-powered contact form for Jekyll
See blog post at http://vitobotta.com/sinatra-contact-form-jekyll/
<!DOCTYPE html>
<html>
<head>
<link href='/stylesheets/contact-form.css' type='text/css' rel='stylesheet' media='screen' />
<meta name="robots" content="noindex, noarchive, noodp, noydir" />
</head>
<body>
<% if @sent == true %>
<div class="notice">Your message has been sent. Thank you!</div>
<% else %>
<% if !@errors.empty? || @failure %>
<div class="notice failure"><%= @failure || "Please fill in all the required fields." %></div>
<% end %>
<form enctype="multipart/form-data" method="post" class="contact-form">
<p class="form-field-row">
<span class="label">
<label for="name">Your Name</label>
<span class="required-field">(required)</span>
</span>
<span class="field">
<input name="name" id="name" type="text" value="<%= @values[:name] %>" autocomplete="off">
<span class="error"><%= @errors[:name] %></span>
</span>
</p>
<p class="form-field-row">
<span class="label">
<label for="email">Email</label>
<span class="required-field">(valid email required)</span>
</span>
<span class="field">
<input name="email" id="email" type="text" value="<%= @values[:email] %>">
<span class="error"><%= @errors[:email] %></span>
</span>
</p>
<p class="form-field-row">
<span class="label">
<label for="website">Website</label>
</span>
<span class="field">
<input name="website" id="website" value="<%= @values[:website] || "http://" %>" type="text">
<span class="error"><%= @errors[:website] %></span>
</span>
</p>
<p class="form-field-row">
<span class="label">
<label for="message">Message</label>
<span class="required-field">(required)</span>
</span>
<span class="field">
<textarea cols="30" rows="8" name="message" id="message"><%= @values[:message] %></textarea>
<span class="error"><%= @errors[:message] %></span>
</span>
</p>
<p class="form-field-row captcha">
<span class="label">
<label for="captcha">Prove you're human!</label>
<span class="required-field">(required)</span>
</span>
<span class="field">
<input name="captcha" id="captcha" value="" type="text" size="4">
<input name="captcha_id" id="captcha_id" value="<%= @captcha_id %>" type="hidden" size="4">
<img src="http://captchator.com/captcha/image/<%= @captcha_id %>" />
<span class="error"><%= @errors[:captcha] %></span>
</span>
</p>
<p class="form-field-row send">
<input name="send-button" id="send-button" value="Submit" onclick="return cforms_validate('', false)" type="submit">
</p>
</form>
<% end %>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.