nuna
2 months ago
301
3
Mix

How to do a success popup if the validateFormAdd is true?

Posted 2 months ago by nuna
$(document).ready( function(){
    $('.brand-form-validation').on('click', function(e) {
        e.preventDefault();      
        validateFormAdd('add_brand').done(function(response){
            if (response.status == true) {
                showToastr('Created', 'Tag Created Successfully!', 'success');
            }else {
                showToastr('Unsuccessful', 'Tag could not be Created!', 'info');
            }
        }
    });

    $('#add_brand').keyup( function(e) {
        e.preventDefault();      
        validateFormAdd('add_brand');
    });

});

The function for the validate form

function validateFormAdd(formName) {
    $("#"+formName).validate({
      rules: {
        name: {
            required: true,
            maxlength: 100,
        },
        store_id: {
            required: true,
        },
        code: {
            required: true,
            maxlength: 100,
        },
        description: {
            maxlength: 255,
        },
      },
    });
  }

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