$(document).ready(function (e){
    $("#donationForm,#contact_us_form").validate({
        ignore: ":hidden",
        errorElement: "em",
        errorPlacement: function ( error, element ) {
            error.addClass( "invalid-feedback" );

            if( $(element).hasClass('select2')){

            }else{
                error.insertAfter( element );
            }
        },
        highlight: function ( element, errorClass, validClass ) {

            $( element ).addClass( "is-invalid" ).removeClass( "is-valid" );
        },
        unhighlight: function (element, errorClass, validClass) {
            $( element ).addClass( "is-valid" ).removeClass( "is-invalid" );

        },submitHandler: function (form) {
            $(".spinner-border").removeClass('d-none');
            $("button[type='submit']").prop('disabled',true);
            form.submit();
        }
    });
});

function submit_donation_form() {
    if ($("#donationForm").valid()) {
        var payment_by = $("input[name='payment_by']:checked"). val();
        if(payment_by=='S'){
            get_stripe();
        }else{
            $("#donationForm").submit();
        }
    }
}
function show_offline_notes(){
    $("#offline_payment_section").removeClass('d-none');
    $("#notes").attr('required',true)
}
function submit_contact_form() {
    if ($("#contact_us_form").valid()) {
        $("#contact_us_form").submit();
    }
}