@ -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,35 +286,47 @@
'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');
if(email.value != null){
var email = document.getElementById('subscribe_email');
$.ajax({
var successMessage = document.getElementById('success-message');
var errorMessage = document.getElementById('error-message')
url: "/subscribe",
function subscribeValidation(){
type:"POST",
if(email.value.length == 0){
data:{
errorMessage.innerHTML="Please provide email address!";
email:email.value,
return false;
},
}
else{
success:function(response){
errorMessage.innerHTML="";
return true;
if (response) {
}
}
// alert(response.success);
function subscribe(){
$('#success-message').text(response.success);
if(!subscribeValidation()){
email.value = '';
return false;
// $("#contactForm")[0].reset();
}
}
else{
$.ajax({
url: "/subscribe",
type:"POST",
data:{
email:email.value,
},
success:function(response){
if (response) {
$('#success-message').fadeOut(5000).text(response.success);
email.value = '';
console.log(response)
// alert(response.success);
// $("#contactForm")[0].reset();
}
},
},
error: function(response) {
error: function(response) {
}
}
});
});
}
}
}
< / script >
}
< / script >
< / html >
< / html >