Answer the question
In order to leave comments, you need to log in
Why is the Bitrix form not sent?
Good afternoon
everyone I tried to attach validation to the Bitrix form, validation passes, but for some reason only with 2 clicks, and the form stopped sending at all
With JS, I’m really bad, I hope someone can help
$("form[name='SIMPLE_FORM_5'] input[name='web_form_submit']").on('click',function(e){
e.preventDefault();
var resName = validateName('form[name="SIMPLE_FORM_5"] input[name="form_text_14"]');
var validateTel = validateTel('form[name="SIMPLE_FORM_5"] input[name="form_text_15"]');
var resText = validateText('form[name="SIMPLE_FORM_5"] textarea[name="form_textarea_16"]',6);
var res = resName && validateTel && resText;
if(!res){
return false;
}
var Form = $(this).parents('form').serialize();
var FormUrl = $(this).parents('form').attr('action');
$.ajax({
type:'post',
url:FormUrl,
beforeSend:function(){
BX.showWait();
},
data:Form,
success:function(data){
if(data !== ""){
if($(data).find('.errortext').length > 0){
$('form[name="SIMPLE_FORM_5"] div.errormess').remove();
$('form[name="SIMPLE_FORM_5"]').prepend("<div class='errormess'>" + $(data).find('.errortext').text() + "</div>");
}else{
$('form[name="SIMPLE_FORM_5"] input[name="form_text_14"]').val("");
$('form[name="SIMPLE_FORM_5"] input[name="form_text_15"]').val("");
$('form[name="SIMPLE_FORM_5"] textarea[name="form_textarea_16"]').val("");
$('form[name="SIMPLE_FORM_5"]').prepend("<div class='success'>Благодарим Вас за сообщение!</div>");
setTimeout(function(){
$('form[name="SIMPLE_FORM_5"]').find('.success').remove();
},3000)
}
}
BX.closeWait();
}
});
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question