<script>
jQuery("#cmbf-phone-<?php echo $id_module; ?>").mask("<?php echo $phone_mask ?>");
jQuery('document').ready(function() {
jQuery('#cmbf-form-<?php echo $id_module; ?> input').focus( function() {
jQuery(this).parents().eq(1).removeClass("valid-error");
});
jQuery('#cmbf-form-<?php echo $id_module; ?>').on('submit', function (event) {
var form = jQuery(this);
var error = false;
form.find('input[type="text"]').each(function() {
if (!jQuery(this).val().length) {
jQuery(this).parents().eq(1).addClass("valid-error");
error = true;
}
});
if (!error)
{
ajaxsendmessage();
}
function ajaxsendmessage() {
jQuery.ajax({
type: 'POST',
url: form.attr('action'),
data: form.serialize(),
cache: false,
beforeSend: function() {
form.find('input[type="submit"]').attr('value', '<?php echo $send_button_after; ?>');
form.find('input[type="submit"]').attr('disabled', 'disabled');
},
success: function () {
form.find('.cmbf-field-container').slideUp('fast');
form.find('.cmbf-success').slideDown("fast");
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
}
event.preventDefault();
});
jQuery('#cmbf-button-container-<?php echo $id_module; ?>').click(function() {
jQuery('#cmbf-form-container-<?php echo $id_module; ?>, #cmbf-obfuscator-<?php echo $id_module; ?>').fadeIn('slow');
});
jQuery('#cmbf-obfuscator-<?php echo $id_module; ?>, #cmbf-form-close-<?php echo $id_module; ?>').click(function() {
jQuery('#cmbf-form-container-<?php echo $id_module; ?>, #cmbf-obfuscator-<?php echo $id_module; ?>').fadeOut('slow');
});
});
</script>