
                <div class="col-12 col-md-8 col-lg-8" id="anggota-{{ $i }}">
                    <div class="card">
                        <div class="card-body" id="list-anggota">
                            <div class="row">
                                <div class="col-6 form-group" @if ($errors->has('nama')) has-error @endif>
                                    <label>Nama</label>
                                    <input type="text" id="nama" name="nama" class="form-control" required="" placeholder="" value="{{ old('nama')}}">
                                    @if ($errors->has('nama'))
                                        <label id="login-error" class="error" for="nama" style="color: red">{{$errors->first('nama')}}</label>
                                    @endif
                                </div>
                                <div class="col-6 form-group" @if ($errors->has('nik')) has-error @endif>
                                    <label>NIK</label>
                                    <input type="text" id="nik" name="nik" class="form-control" required="" placeholder="" value="{{ old('nik')}}">
                                    @if ($errors->has('nik'))
                                        <label id="login-error" class="error" for="nik" style="color: red">{{$errors->first('nik')}}</label>
                                    @endif
                                </div>
                            </div>
                                <div class="row">
                                    <div class="col-6 form-group" @if ($errors->has('email')) has-error @endif>
                                        <label>E-mail</label>
                                        <div class="input-group">
                                            <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                    <i class="fas fa-envelope"></i>
                                                </div>
                                            </div>
                                            <input type="email" id="email" name="email" class="form-control email" required="" placeholder="" value="{{ old('email')}}">
                                        </div>
                                        @if ($errors->has('email'))
                                            <label id="login-error" class="error" for="nama_depan" style="color: red">{{$errors->first('email')}}</label>
                                        @endif
                                    </div>
                                    <div class="col-6 form-group" @if ($errors->has('telepon')) has-error @endif>
                                        <label>Telepon</label>
                                        <div class="input-group">
                                            <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                    <i class="fas fa-phone"></i>
                                                </div>
                                            </div>
                                            <input type="number" id="telepon" name="telepon" class="form-control number" required="true" placeholder="" value="{{ old('telepon')}}">
                                        </div>
                                        @if ($errors->has('telepon'))
                                            <label id="login-error" class="error" for="telepon" style="color: red">{{$errors->first('telepon')}}</label>
                                        @endif
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <button type="button" class="btn btn-primary" onclick="tambahAnggota()" name="tambah-anggota" id="tambah-anggota">Tambah Anggota</button>
                        </div>
                </div>
                <div class="col-12 col-md-4 col-lg-4">
                    <div class="row" id="parent-kegiatan">
                        {{ view('form_kegiatan', [
                            'kegiatan' => $kegiatan,
                            'konferensi' => $konferensi,
                            'i' => 0
                        ]) }}
                    </div>
                    <div>
                        <button type="button" class="btn btn-primary" onclick="tambahKegiatan()" name="tambah-kegiatan" id="tambah-kegiatan">Tambah kegiatan</button>
                    </div>
                    <hr>
                </div>
            </div>
            <div class="card-footer text-right">
                <button class="btn btn-primary mr-1" type="submit">Daftar</button>
                <button class="btn btn-secondary" type="reset">Reset</button>
            </div>
        </div>
        </form>
    </section>
@endsection

@push('js')
    <script>
        $(document).ready(function () {
        //change selectboxes to selectize mode to be searchable
        $("#instansi").select2();
        });
    </script>

    <script>
        function cekKegiatan(id){
            var value = document.getElementById(id).value;
            if(value == '498633a9-082c-4a4a-9dbd-e20b678ec15e'){
                $('#grup-konferensi').hide();
                $('#tambah-kegiatan').hide();
                var konferensi = document.getElementById("konferensi");
                konferensi.required = false;
                document.getElementById('konferensi').value = "";
            } else {
                $('#grup-konferensi').show();
                $('#tambah-kegiatan').show();
                var konferensi = document.getElementById("konferensi");
                konferensi.required = true;
            }
        }

    </script>

    <script>
        var i = 1;
        function tambahKegiatan(){
            let token = '{{ csrf_token() }}';

            if (i === undefined) {
                i = 1;
            }

            var request = $.ajax({
                url: '{{ route('registrasi.form-kegiatan.add') }}',
                type:'POST',
                dataType: 'html',
                data: {_token:token, i:i},
                success: function (result) {
                    $('#parent-kegiatan').append(result);
                },

                error: function(error) {
                    alert('periksa koneksi anda');
                }
            });

            i++;
        }

        function hapusKegiatan(id){
            $('#'+id).remove();
        }
    </script>

<script>
    var i = 1;
    function tambahAnggota(){
        let token = '{{ csrf_token() }}';

        if (i === undefined) {
            i = 1;
        }

        var request = $.ajax({
            url: '{{ route('registrasi.form-anggota.add') }}',
            type:'POST',
            dataType: 'html',
            data: {_token:token, i:i},
            success: function (result) {
                $('#parent-anggota').append(result);
            },

            error: function(error) {
                alert('periksa koneksi anda');
            }
        });

        i++;
    }

    function hapusKegiatan(id){
        $('#'+id).remove();
    }
</script>
@endpush
