1 year ago

Remove error message after open second time of modal

Posted 1 year ago by gidaban79

Hello guys,

i am trying to do validation of adding some value to database in modal.

So far validation working well, However when user will press close modal and will open again previously message still is showed.

js script

$('.saveService').on('click', function () {
                    let msg = $('#msg');
                        type: 'PUT',
                        url: '{{route('')}}',
                        data: {
                            name: $('#service').val()
                        }, error: function (data) {
                        success: function (data) {

and modal

<div class="modal fade" id="services" tabindex="-1" role="dialog" aria-labelledby="servicesLabel"
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="servicesLabel">Add New Service</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            {{Form::label('service','Service',['class' => 'form-control-label'])}}
                            <div id="msg"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-warning btn-sm" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-success btn-sm saveService">Save changes</button>

Please sign in or create an account to participate in this conversation.