Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("form").submit(function(event) {
- event.preventDefault();
- var phone_input = $(this).find("input[type=tel]");
- var phone_number = phone_input.val().replace(/[^0-9]/g,"");
- if (phone_number.length === 0 ) {
- phone_input.notify("Введите номер телефона", {position:"bottom" , className: 'error'})
- }
- if (phone_number.length < 12 && phone_number.length >= 4) {
- phone_input.notify("Номер введён не полностью", {position:"bottom" , className: 'warn', gap: 0, autoHideDelay: 3000});
- }
- if (phone_number.length === 12) {
- var data = $(this).serializeArray();
- data.push ({name: 'client', value: client_info});
- data.push ({name: 'href', value: href});
- data.push ({name: 'search', value: search});
- data.push ({name: 'ref', value: ref});
- var thisForm = $(this);
- var thisBtn = thisForm.find("button");
- $.ajax({
- url: 'php/mail.php',
- type: 'POST',
- data: data,
- success: function(data){
- console.log(data);
- thisBtn.notify("Заявка принята", {position:"bottom center", className: 'success'});
- thisForm.find("input").val("");
- thisForm.trigger("reset");
- },
- error: function(data) {
- if (data === 'error') {
- thisBtn.notify("Ошибка на сервере", {position:"bottom center", className: 'error'} );
- thisForm.find("input").val("");
- thisForm.trigger("reset");
- }
- }
- });
- return false;
- }
- });
Add Comment
Please, Sign In to add comment