hexo-tag-googleform
Version:
Google Form tag plugin for Hexo
36 lines (32 loc) • 891 B
JavaScript
$(document).ready(function () {
//clean up empty tags
$('.google-form-wrapper p, .google-form-wrapper br')
.filter(function () {
return $(this).html() === '';
})
.remove();
//add required class to required elements
$('.google-form-wrapper form')
.find('.ss-item-required input, .ss-item-required textarea')
.filter(function () {
return $(this).attr('name').match(/entry\.\d\.single/);
})
.addClass('required');
//validate the form
$('.google-form-wrapper form').validate({
submitHandler: function (form) {
$(form).ajaxSubmit({
success: function (data) {
if (data) {
$(form).hide(200, function () {
$(this).prev('.success-msg').fadeIn('slow');
});
}
},
error: function (data) {
console.error(data);
}
});
}
});
});