Skip to content

Instantly share code, notes, and snippets.

@DeskWOW
Created January 8, 2015 02:19
Show Gist options
  • Save DeskWOW/e2f94faffd35ff25cc03 to your computer and use it in GitHub Desktop.
Save DeskWOW/e2f94faffd35ff25cc03 to your computer and use it in GitHub Desktop.
An example of adding list case custom fields to your contact form and making them required.
<!-- HTML -->
<div class="form-group div-category">
<label for="ticket_custom_category" class="control-label">Category ({{system.snippets.required}}):</label>
{{ ticket_custom_category }}
</div>
<div class="form-group div-favorite-color">
<label for="customer_custom_favorite_color" class="control-label">Favorite Color ({{system.snippets.required}}):</label>
{{ customer_custom_favorite_color }}
</div>
<!-- JavaScript -->
<script>
$(document).ready(function () {
/* The code below makes your default (top) value blank for each custom field, forcing the user to
select an option. This assumes your list custom fields' first option is something like "---",
"Please select an option", etc. */
$(".form-group select").each(function() {
$(this).find("option:first").val("");
$(this).rules("add", { required:true, messages: { required: "Field is required." } });
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment