I
I
IgorRastarov2017-03-06 15:42:20
JavaScript
IgorRastarov, 2017-03-06 15:42:20

How to make fancybox not hide if no field is filled?

Hello. I have a feedback form on Bitrix. Here is the template

<?
if(!defined("B_PROLOG_INCLUDED")||B_PROLOG_INCLUDED!==true)die();
?>
<div class = "popul" id = "call">
<div class = "title">Обратный звонок</div>
<?if (!empty($arResult["ERROR_MESSAGE"])) {?>
                    <? foreach ($arResult["ERROR_MESSAGE"] as $v) { ?>                  
                    <? ShowError($v); ?>
                    <? } ?>
                    <script type="text/javascript">
                        jQuery(document).ready(function() {
                            jQuery('#call').modal('show');
                        });
                    </script>
            <? }
            if (strlen($arResult["OK_MESSAGE"]) > 0) {
            ?>  
                    <?=$arResult["OK_MESSAGE"] ?>
                <script type="text/javascript">
                    jQuery(document).ready(function() {
                        jQuery('#call').modal('show');
                    });
                </script>
            <? }
?>

<form action="<?=POST_FORM_ACTION_URI?>" method="POST">
<?=bitrix_sessid_post()?>
<fieldset>
      <label><?=GetMessage("MFT_NAME")?><?if(empty($arParams["REQUIRED_FIELDS"]) || in_array("NAME", $arParams["REQUIRED_FIELDS"])):?><span>*</span></label><?endif?>
        <input type="text" name="user_name" value="<?=$arResult["AUTHOR_NAME"]?>">
</fieldset>
<fieldset>
      <label><?=GetMessage("MFT_PHONE")?><?if(empty($arParams["REQUIRED_FIELDS"]) || in_array("PHONE", $arParams["REQUIRED_FIELDS"])):?><span>*</span></label><?endif?>
    <input type="number_format" name="user_phone" value="<?=$arResult["AUTHOR_PHONE"]?>">
</fieldset>
<!--	<button type="submit" name="submit"><?=GetMessage("MFT_SUBMIT")?></button> !-->
<input class="btn" type="submit" name="submit" value="Перезвонить">
</form>
</div>

If the name or phone number is not filled in, fancybox should not be hidden. And when I click on Call Back, if the fancybox field is not filled out, it just goes away.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2017-03-06
@IgorRastarov

If you have fancybox. Therefore, you need to call fancybox. You call some kind of modal window.
Replace jQuery('#call').modal('show'); on jQuery.fancybox(jQuery('.yourelement')) and don't forget to call wrapCSS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question