Good luck!
Need your opinion ...
A page has connected scripts js. Errors in the debugger is not detected.
On the details page of the product there is a button "book", which is initially inactive.
In going to this page after the checkbox, function works js, which makes the active button to submit the form.
By clicking on the button - function works AJAX.
The problem is that once again works through AJAX and activity buttons - with no errors.
What nonsense is this, do not even know where to dig and how to find this needle in a haystack.
Thank you!
<script type="text/javascript" src="my.js"></script>
Locate at page my.js file with my js code:
$(function() {
$('#search_result').dblclick(function() {
$(this).hide();
});
$("#search input[type=submit]").click(function() {
$.ajax({
url:"/engine/controller/search.php",
type:"POST",
dataType: 'json',
data: {id: $("input[name=search_word]").val()},
success:function(result){
GetSearchResult(result);
}
});
return false;
});
$("input[name=tos]").click(function() {
var checked_status = this.checked;
if (checked_status == true) {
$(".tos .but").removeAttr("disabled").addClass('but_active');
} else {
$(".tos .but").attr("disabled", "disabled").removeClass('but_active');
}
});
$("#rez").click(function() {
var email = $("#email").val();
var name = $("#name").val();
var phone = $("#phone").val();
var info = $("#info").val();
var id = $("#id").val();
$.ajax({
type: 'POST',
url: '/rezervation.php',
dataType : 'json',
data: 'email='+email+'&name='+name+'&phone='+phone+'&info='+info+'&id='+id,
success: function(data){
var block = '#mes';
if (data.statuse == 1 ) {block = ''; $('.tos table').hide();}
$('.tos '+block).html(''+data.message[0]+'');
}
});
});
function GetSearchResult(result){
var html ='';
if (result.message == undefined) {
html = 'ID: '+result[4].val+''+result[1].val+''+result[5].val+' €';
} else {
html = ''+result.message+'';
}
$("#search_result div").html(html);
$("#search_result").show();
}
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validate(){
var email = $("#email").val();
$("#email").css('border','auto');
if (!validateEmail(email)) {
alert('Email is not correct');
$("#email").css('border','1px solid red');
$("#email").val('');
//$(".tos .but").attr("disabled", "disabled").removeClass('but_active');
}
return false;
}
});
Here is HTML:
<label>
<input type="checkbox" name="tos" value="1"> I read Terms and Conditions
</input></label>
Name
<input type="text" class="field" id="name" name="data[name]">
E-mail
<input id="email" type="text" onblur="validate();" class="field" name="data[mail]">
Telefon
<input type="text" class="field" id="phone" name="data[phone]">
Info
<textarea class="textfield" id="info" name="data[info]"></textarea>
<input type="hidden" name="id" id="id" value="40">
Book
<input type="hidden" name="ac" value="send_msg"></input></input></input></input></input>