So I have a form that has 2 buttons on the botton.
<div class="col-xs-12">
<div class="submit-button-mobile">Submit</div>
</div>
<div class="col-xs-12">
<a href="/how_to_book.php">
<div class="how-to-book-button-mobile">
How to book?
</div>
</a>
</div>
originaly i had onclick="send_message();"
on the submit-button-mobile
(which worked for desktop but not on mobile. Also the tag was also not clickable on mobile.
I've searched here and found this answer to make it work on mobile
$('.submit-button-mobile').on('click touchstart', send_message);
$('.how-to-book-button-mobile').on('click touchstart', function() {
window.location.href = "/how_to_book.php";
});
And still have the same problem, unclickable on mobile (tried on chrome developer tools with mobile view and tried on iphone and android).
send_message() is in another .js file included at the top of file. It looks like this
function send_message()
{
var a=document.forms["Form"]["name"].value;
var b=document.forms["Form"]["email"].value;
var c=document.forms["Form"]["message"].value;
var d=document.forms["Form"]["surname"].value;
document.getElementById("contact_message").innerHTML = "Sending your message... Please wait.";
loadXMLDoc(a, b, c, d);
}
//pomocna funkcija za validaciju emaila
function validateEmail(email) {
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
}
//funkcija za slanje emaila
function loadXMLDoc(name, mail, message, surname)
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("contact_message").innerHTML=xmlhttp.responseText;
document.getElementById("contact_message2").innerHTML=xmlhttp.responseText;
}
}
// xmlhttp.open("GET","send_enquiry.php",true);
xmlhttp.open("POST","send_enquiry.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("name=" + name + "&email=" + mail + "&message=" + message + "&surname=" + surname);
xmlhttp.send();
}