Aaron
Aaron

Reputation: 11673

Script becomes unresponsive crashing firefox

Why does this script cause an error on submit in firefox? It is using jquery.

$(document).ready(function(e) {
    $('#errorMessage').hide();
    $('#form').submit(function() {

        var firstname = $('#formFirstname').val();

        if(firstname == '') {
            $('#errorMessage').html('Please enter your Name.');
            $('#errorMessage').fadeIn();
        }

        else {
            $('#errorMessage').html('Please wait a moment as the form Submits.');
            $('#form').submit();
        }
        return false;
    })
});

Upvotes: 0

Views: 336

Answers (2)

xdazz
xdazz

Reputation: 160853

You are aliasing the jQuery to e.

Change $(document).ready(function(e) { to $(document).ready(function() {

Or jQuery(document).ready(function($) {

Edit:

Although it may not cause the error, in your code e is also jQuery's alias, e('#form') will also work.

Upvotes: 1

Manuel van Rijn
Manuel van Rijn

Reputation: 10305

$('#form').submit();

causes recursion?

Upvotes: 3

Related Questions