Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Last active January 3, 2016 13:39
Show Gist options
  • Select an option

  • Save msmithstubbs/8470694 to your computer and use it in GitHub Desktop.

Select an option

Save msmithstubbs/8470694 to your computer and use it in GitHub Desktop.
Catch blank phone field
{% if settings.notify_me_form %}
<div class="notify_form" id="notify-form-{{ product.id }}" {% if product.available %}style="display:none"{% endif %}>
<form action="/contact" method="post" data-first-variant="{{product.variants.first.id}}" id="BIS_form" onsubmit="return createNotification{{product.id}}(this); return false;">
<p>
<label for="contact[email]"><strong>Contact me with stock price and availability:</strong></label>
</p>
<p>
<input required type="phone" name="contact[email]" id="contact[email]" placeholder="EMAIL" value="{{ contact.fields.email }}" style="display:inline;margin-bottom:0px" />
</p>
<p>
<input required type="phone" name="metadata[phone]" id="contact[phone]" placeholder="PHONE" value="{{ contact.fields.email }}" style="display:inline;margin-bottom:0px" />
</p>
<p>
<input class="submit" type="submit" value="Send" style="margin-bottom:0px" />
</p>
<p class="BIS_response"></p>
</form>
</div>
<script>
var createNotification{{product.id}} = function(form) {
if ($('[name="metadata[phone]"]').val() == '') {
alert('Hey, you forgot to enter a phone number!');
return false;
}
if (BISMetadataForm) {
var bis = new BISMetadataForm(form);
}
return false;
};
var clearBISResponse = function() {
$('#BIS_form .BIS_response').text('');
};
$(function() {
$('#BIS_form input').on('focus change', clearBISResponse);
$('.product_form select').on('change', clearBISResponse);
});
</script>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment