var URL = 'https://gzm7nm9e7f.execute-api.ap-southeast-1.amazonaws.com/prod/contact'; $('#contact_form').submit(function (event) { event.preventDefault() var errors = []; $("#contact_form input[input-empty-validate]").each(function (elem) { if (!$(this).val()) { errors.push("Please provide input for " + $(this).attr("id")); } }); var phonenoPattern = /^\+?\d+(\d\-|\d)+\d$/; if (!phonenoPattern.test($("#contact_form").find("#mobile").val())) { errors.push("Please enter a valid telephone or mobile."); } var pattern = /^(([^<>()\[\]\\.,;:\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,}))$/; if (!pattern.test($("#contact_form").find("#email").val())) { errors.push("Please enter a valid email"); } if (errors.length) { $('#sucess').css('display', 'block'); $("#contact_form").find("#sucess").text(errors[0]).css("color", "red"); } else { var data = { name: $('#name').val(), email: $('#email').val(), phone: $('#mobile').val(), description: $('#requirement').val(), project: "prestigeelysianbangalore.in" } $.ajax({ type: 'POST', url: URL, dataType: 'json', contentType: 'application/json', data: JSON.stringify(data), beforeSend: function () { console.log("sin"); $('#spin').css('display', 'block'); }, success: function () { $('#name').val(''); $('#email').val(''); $('#mobile').val(''); $('#requirement').val(''); $('#sucess').css('display', 'block'); $('#spin').css('display', 'none'); $('#sucess').html('Thanks for your query! we will get back to you shortly').css('color','green'); }, error: function () { } }) } })
Need Price Sheet ?