$(document).ready(function () {
$.validator.setDefaults({
submitHandler: function () {
$('#search').submit(function () {
var city = $("#city").val();
var adults = $("#adults").val();
var children = $("#children").val();
var SDate = $("#hotelStartDate").val();
var EDate = $("#hotelEndDate").val();
SDate = SDate.substr(6, 4) + '-' + SDate.substr(3, 2) + '-' + SDate.substr(0, 2);
EDate = EDate.substr(6, 4) + '-' + EDate.substr(3, 2) + '-' + EDate.substr(0, 2);
jQuery(":submit", this).css("display", "none");
jQuery(":submit", this).after("<span class='button nice awesome green large radius'>Searching...</span>");
location.href = 'http://www.dhitrax.com/destination.php?checkin=' + SDate + '&checkout=' + EDate + '&city=' + city + '&adults=' + adults + '&children=' + children;
return false;
});
},
highlight: function (input) {
$(input).addClass("ui-state-highlight");
},
unhighlight: function (input) {
$(input).removeClass("ui-state-highlight");
}
});
$().ready(function () {
$.fn.themeswitcher && $('<div/>').css({
position: "absolute",
right: 10,
top: 10
}).appendTo(document.body).themeswitcher();
$("#search").validate({
rules: {
city: "required",
hotelStartDate: "required",
hotelEndDate: "required"
},
messages: {
City: "Please type your destination",
hotelStartDate: "Select check in Date",
hotelEndDate: "Select check out Date"
}
});
});
});
$(document).ready(function () { $.validator.setDefaults({ submitHandler: function () { $(‘#search’).submit(function () { var city =
Share
You shouldn’t bind an event handler to the
submitevent inside of the existingsubmitHandlerjQuery validate provides. It’s taking two clicks to submit the form because the first time you submit, the handler is bound and the second time you submit the handler is executed.This should be as simple as moving your code into the
submitHandler: