@ -211,10 +211,11 @@
< h1 class = "mb-20 text-white link-title" > Free Newsletter< / h1 >
< h1 class = "mb-20 text-white link-title" > Free Newsletter< / h1 >
< p > Subscribe for our free newsletter< / p >
< p > Subscribe for our free newsletter< / p >
< div class = "custom-search" >
< div class = "custom-search" >
< input type = "text" name = "email" id = "subscribe_email" class = "custom-search-input" placeholder = "Email address" required >
< input type = "text" name = "email" id = "subscribe_email" class = "custom-search-input" placeholder = "Email address" onkeyup = "subscribeValidation()" >
< button class = "custom-search-botton" onclick = "subscribe()" > Subscribe< / button >
< button class = "custom-search-botton" onclick = "subscribe()" type = "submit" > Subscribe< / button >
< / div >
< / div >
< span class = "success-message" id = "success-message" > < / span >
< span class = "success-message" id = "success-message" > < / span >
< span class = "success-message" id = "error-message" > < / span >
< / div >
< / div >
< div class = "col footer-socials" >
< div class = "col footer-socials" >
< h1 class = 'text-white link-title' > Join Our Social Community< / h1 >
< h1 class = 'text-white link-title' > Join Our Social Community< / h1 >
@ -285,32 +286,44 @@
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
}
});
});
function subscribe(){
var email = document.getElementById('subscribe_email');
var email = document.getElementById('subscribe_email');
var successMessage = document.getElementById('success-message');
var errorMessage = document.getElementById('error-message')
if(email.value != null){
function subscribeValidation(){
if(email.value.length == 0){
errorMessage.innerHTML="Please provide email address!";
return false;
}
else{
errorMessage.innerHTML="";
return true;
}
}
function subscribe(){
if(!subscribeValidation()){
return false;
}
else{
$.ajax({
$.ajax({
url: "/subscribe",
url: "/subscribe",
type:"POST",
type:"POST",
data:{
data:{
email:email.value,
email:email.value,
},
},
success:function(response){
success:function(response){
if (response) {
if (response) {
$('#success-message').fadeOut(5000).text(response.success);
// alert(response.success);
$('#success-message').text(response.success);
email.value = '';
email.value = '';
console.log(response)
// alert(response.success);
// $("#contactForm")[0].reset();
// $("#contactForm")[0].reset();
}
}
},
},
error: function(response) {
error: function(response) {
}
}
});
});
}
}
}
}