Answer the question
In order to leave comments, you need to log in
How to interrupt form submission in bitrix?
Good afternoon!
I can’t figure out how to stop submitting the form to Bitrix, this method doesn’t work:
var formID = "form_" + "<?=CUtil::JSEscape($arResult['FORM_ID'])?>";
var form = BX(formID);
var sourceEl = BX.findChild(form, { "tag":"select", "attr": { "name": "SOURCE_ID" } }, true, false);
BX.bind(form, 'submit', function(){
var id = sourceEl.value;
if(id == 20){
alert(id);
return false;
}
});
Answer the question
In order to leave comments, you need to log in
have you tried that?
BX.bind(form, 'submit', function(event){
var id = sourceEl.value;
if(id == 20){
event.preventDefault() ;
event.stopPropagation();
alert(id);
}
}) ;
If it’s not so easy to get into the form code, then it’s easier to set disabled for an option that does not need to be selected, you can also hang custom validation on this select and if the form is sent via submit, then the sending will not be completed
and what's stopping you from sending via jikveri or vanillage
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question