Skip to content

Instantly share code, notes, and snippets.

@rohandalvi
Created May 9, 2012 16:36
Show Gist options
  • Save rohandalvi/2646370 to your computer and use it in GitHub Desktop.
Save rohandalvi/2646370 to your computer and use it in GitHub Desktop.
<div class="groups-tagit">
{{ form.groups.label_tag() }}
{{ form.groups }}
</div>
var displayAnotherError = function(field, message) {
var group = field.parents('.groups-tagit')
group.addClass('error')
group.append('<span class="help-inline">' +
'<p class="help-block">' + message + '</p>' + '</span>')
}
and modify the validateGroup method like:
validateGroup: function(group, field) {
var name = group.children('span').text();
if (name.match(/^[a-zA-Z0-9 .:,-]*$/g) === null) {
displayAnotherError(field, gettext('Groups can only contain ' +
'alphanumeric characters, dashes, ' +
'spaces.'));
// HACK: Do this without dirty DOM manipulation.
group.children('a.tagit-close').click();
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment