Dranreb
Dranreb

Reputation: 107

Javascript preventing the submit button to work

I have a js that acts as a "fade" page transition:

jQuery('body').css('display','none');

jQuery(document).ready(function() {
    jQuery('body').fadeIn();
    jQuery('a').on('click',function(event){
        var thetarget = this.getAttribute('target')

        if (thetarget !="_blank" ) {
            var thehref = this.getAttribute('href')

            event.preventDefault();
            console.log(thehref)
            if(thehref){
                console.log('not null')
                jQuery('body').fadeOut(function(){
                    window.location = thehref
                });
            }
        }
    });
});

setTimeout(function(){
    jQuery('body').fadeIn();
},1000)

and I have this form:

<form id = "create_faculty_formcontainer" action = "" method = "post">
    <input type = "text" name = "fac_idnumber" placeholder="ID Number" required/><br/><br/>
    <input type = "text" name = "fac_firstname" placeholder="First Name" required/><br/><br/>
    <input type = "text" name = "fac_lastname" placeholder="Last Name" required/><br/><br/>

    <input type = "password" id = "password_fac" name = "fac_password" placeholder="Password" required/>

    <br/>

    <input type = "submit" name = "fac_submit" value = "       sign up       ">
</form>

Whenever I click the submit button, nothing happens. So I tried erasing my javascript and the button worked. The js must have been causing the submit button not to work and I couldn't actually figured what is it or how to fix it. Any thoughts on how can I keep the javascript and make the submit button work too?

Upvotes: 0

Views: 32

Answers (1)

Dranreb
Dranreb

Reputation: 107

I've figured it out. Erasing the event.preventDefault(); settles it. Thanks to Korgrue

Upvotes: 1

Related Questions