Sunday, April 2, 2017

jquery triggered after validation error

i am using laravel 5.3 with laravelcollective/html 5.2.. i made a checkbox that if that checked, a hidden input will come out and if i uncheck it the input will be hidden.. and after the validation request error from laravel the checkbox remain checked but the hidden input didnt show up.. please i need help.. thanks..

my checkbox html:

<label>
{!! Form::checkbox('penerima_beda', '1', null, ['id' => 'penerima_beda']) !!}Penerima Berbeda
</label>

and here is my jquery:

$("#penerima_beda").click(function() {
        if(this.checked){
            $("#panel_penerima").css("display", "block");
            $("#nama_penerima").attr("required", "required");
            $("#no_telp_penerima").attr("required", "required");
            $("#alamat_penerima").attr("required", "required");
            //console.log(this);
        }else if(!this.checked){
            $("#panel_penerima").css("display", "none");
            $("#nama_penerima").removeAttr("required");
            $("#no_telp_penerima").removeAttr("required");
            $("#alamat_penerima").removeAttr("required");
        }
    });



via Denny Rustandi

Advertisement