首页 > 解决方案 > 使用 JavaScript 检查频道 ID

问题描述

我的表格是这样的,它可能有手动社交网络

社交网络

我想让用户输入频道的 ID,使用@.

例如

用户可以使用 URL 输入,例如https://t.me/oxbir

如何使用 JavaScript 进行验证?

我不想输入 URL,我想输入频道的 if。@oxbir

    function showDynamicSocial() {
        let html = '' +
            '@foreach(auth()->user()->socials as $social)\n'+
            '<div class="col-md-6 position-relative">\n' +
            '<i class="fas fa-times text-danger position-absolute"></i>' +
            '<div class="row">\n' +
            '<div class="col-md-4">\n' +
            '<div class="form-group">\n' +
            '<label for="social_id">Social Network</label>\n' +
            '<select id="social_id" name="social_id[]" class="form-control">\n' +
            '@foreach($socials as $socialData)\n'+
            '<option value="{{ $socialData->id }}" {{ $socialData->id == $social->id ? 'selected' : ''}}>\n'+
            '{{ $socialData->name }}\n' +
            '</option>\n' +
            '@endforeach\n' +
            '</select>\n' +
            '</div>\n' +
            '</div>\n' +
            '<div class="col-md-8">\n' +
            '<div class="form-group">\n' +
            '<label for="link">Profile ID</label>\n' +
            '<input id="link" value="{{ $social->pivot->link }}" name="link[]" class="form-control">\n' +
            '</div>\n' +
            '</div>\n' +
            '</div>\n' +
            '</div>\n ' +
            '@endforeach';
        $('#showSocial').append(html);
    }

javascript

$('div .btn-next').on('click', function() {
    var parent_fieldset = $(this).parents('fieldset');
    var next_step = true;
    var current_active_step = $(this).parents('div').find('.form-wizard.active');
    var progress_line = $(this).parents('div').find('.progress-line');
    if( next_step ) {
        parent_fieldset.fadeOut(400, function() {
            current_active_step.removeClass('active').addClass('activated').next().addClass('active');
            bar_progress(progress_line, 'right');
            $(this).next().fadeIn();
            scroll_to_class( $('.wizards'), 20 );
        });
    }

});

标签: javascriptlaravel

解决方案


推荐阅读