$('.toggleCollapse').on('click', function() {
// Alert message
// alert('Toggling footer collapse');
// Check if the screen width is less than or equal to 768px (common mobile breakpoint)
if ($(window).width() <= 768) {
$('body').toggleClass('noscroll');
}
});
$(document).on('keypress', '#Name', function() {
// alert('ddd')
if (event.charCode != 0) {
var regex = new RegExp("^[a-zA-Z ]+$");
var key = String.fromCharCode(
!event.charCode ? event.which : event.charCode
);
if (!regex.test(key)) {
event.preventDefault();
return false;
}
}
});
$(document).on('keypress', '#Mobile', function() {
// alert('ddd')
if (event.charCode != 0) {
var regex = new RegExp("^[0-9 ]+$");
var key = String.fromCharCode(
!event.charCode ? event.which : event.charCode
);
if (!regex.test(key)) {
event.preventDefault();
return false;
}
}
});
$(document).on('keypress', '#PinCode', function() {
// alert('ddd')
if (event.charCode != 0) {
var regex = new RegExp("^[0-9 ]+$");
var key = String.fromCharCode(
!event.charCode ? event.which : event.charCode
);
if (!regex.test(key)) {
event.preventDefault();
return false;
}
}
});
$(document).on('click', '.close-supprt-modal', function() {
var parentWindow = $(this).parents('.form-horizontal').attr('class');
// alert(parentWindow);
// $('.'+parentWindow)[0].reset();
// $('.'+parentWindow)[1].reset();
$('#frmContact')[0].reset();
$(".form-group").removeClass("has-error");
$(".error-help-block").remove();
});
$(document).on('click', '.btn-close', function() {
var parentWindow = $(this).parents('.form-horizontal').attr('class');
// alert(parentWindow);
// $('.'+parentWindow)[0].reset();
// $('.'+parentWindow)[1].reset();
$('#frmContact')[0].reset();
$(".form-group").removeClass("has-error");
$(".error-help-block").remove();
});
$(document).on('keyup', '#frmContact :input', function() {
//$("form#frmContact :input").each(function () {
var input = $(this);
if (input.val().length > 0) {
input.parent().removeClass('has-error');
if (input.parent().children().last().hasClass('error-help-block')) {
input.parent().children().last().remove();
}
}
//});
});
$("#frmContact").submit(function(e) {
e.preventDefault();
$(".form-group").removeClass("has-error");
$(".error-help-block").remove();
MasterAffiliate.runWaitMe($("body"));
var formUrl = $("#frmContact").attr("action");
$.ajax({
type: "POST",
url: formUrl,
data: $("#frmContact").serialize(),
dataType: "JSON",
success: function(data) {
if (data.success) {
$('#frmContact')[0].reset();
$('#display_errors').html(
'\n\
×\n\
' + data.msg + ''
);
}
// window.location = data.url;
},
error: function(jqXhr) {
if (jqXhr.status === 422) {
//process validation errors here.
var errors = jqXhr.responseJSON
.errors; //this will get the errors response data.
$.each(errors, function(key, value) {
$(".form-group")
.find("[name='" + key + "']")
.closest(".form-group")
.removeClass("has-success")
.addClass("has-error");
$(".form-group")
.find("[name='" + key + "']")
.parent()
.append(
'' +
value[0] + ""
);
});
MasterAffiliate.stopWaitMe($("body"));
}
},
complete: function() {
MasterAffiliate.stopWaitMe($("body"));
},
});
});
});