Last active
October 30, 2023 15:56
-
-
Save TrywaR/96be11f2c95b05482e7199d1c57cfd6f to your computer and use it in GitHub Desktop.
[ FormFullBleat ] jQeury
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// _________________ // | |
// [ FormFullBleat ] | |
// Параметры | |
var | |
block_form = '#contact_form', //Силектор блока с формой | |
this_form = 'form' //Силектор формы | |
// Параметры x | |
// Обработка ввода данных | |
// - Только цифры | |
$(''+block_form+' '+ this_form +' input[name^=phone]').on('keydown', function(e){ | |
if(e.key.length == 1 && e.key.match(/[^0-9+\(\)-]/)) | |
return false | |
}) | |
// Обработка ввода данных x | |
// Обработка отправки данных | |
$(document).on('submit', block_form, function(event) { | |
event.preventDefault() | |
// - Антиспам | |
if ($(''+block_form+' '+ this_form +'').find('._org').length <= 0) | |
$(''+block_form+' '+ this_form +'').append('<input type="text" name="org" value="" class="_org" style="visability:hidden; height: 0; width: 0; padding: 0; border:none;"/>') | |
// - Отправка | |
$.post('/', $(this).serialize(), function(d){ | |
if (d) | |
$(''+block_form+'').addClass('_complete_') | |
}) | |
}) | |
// Обработка отправки данных x | |
// [ FormFullBleat ] x | |
// _________________ // |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment