-1

i think that i have a sintax error in this code

<script type="text/javascript">
    $(document).ready(function() {
        $("#send").submit(function() {
            $.post("validation.php", {
                nameRegist: $('#nameRegist').val(),
                emailRegist: $('#emailRegist').val(),
                myPasswordRegist: $('#myPasswordRegist').val(),
                pass2Regist: $('#pass2Regist').val()

            }, function(data) {
                if (data == 'nomeInvalido') {
                    $("#msgbox1").fadeTo(200, 0.1, function() {
                        $(this).html('Nome inválido').addClass('messageboxerror1').fadeTo(900, 1);
                    });
                } else if (data != 'emailValido' || data != 'emailRegistado') {
                    $("#msgbox1").fadeTo(200, 0.1, function() {
                        $(this).html('Email inválido').addClass('messageboxerror1').fadeTo(900, 1);
                    });
                } else if (data == 'passInvalida') {
                    $("#msgbox1").fadeTo(200, 0.1, function() {
                        $(this).html('Pass inválida').addClass('messageboxerror1').fadeTo(900, 1);
                    });
                } else if (data == 'dadosInvalidos') {
                    $("#msgbox1").fadeTo(200, 0.1, function() {
                        $(this).html('Dados inválidos').addClass('messageboxerror1').fadeTo(900, 1);
                    });
            }
            } else {
                $("#msgbox1").fadeTo(200, 0.1, function() {
                    $(this).html('Registo Efectuado.....').addClass('messageboxok1').fadeTo(900, 1, function() {
                        document.location = 'emprego.php';
                    });
                }
            return false;
            });
        });
</script>

I'm completely lost in quotes

if someone can help me, i really appreciate

thanks

6
  • Are you getting an error message? Commented Apr 8, 2011 at 1:56
  • no but i check in this online tool and give me errors javascriptlint.com/online_lint.php and the script don't do what is supposed, so i suspect that is a syntax problem Commented Apr 8, 2011 at 1:57
  • "i think?" what makes you doubt? Commented Apr 8, 2011 at 1:59
  • i have 99% sure that i have problems in quotes and parenthesis Commented Apr 8, 2011 at 2:00
  • What errors are you seeing when you run your code through that javascript validation site? I use jslint (jslint.com) and it gives descriptive, useful error messages. I see just now you say that you believe you may have some mismatching quotes/parens. Are you using a text editor which could help you? Commented Apr 8, 2011 at 2:01

2 Answers 2

2

You've got a number of issues, see comments below:

$(document).ready(function() {
    $("#send").submit(function() {
        $.post("validation.php", {
            nameRegist: $('#nameRegist').val(),
            emailRegist: $('#emailRegist').val(),
            myPasswordRegist: $('#myPasswordRegist').val(),
            pass2Regist: $('#pass2Regist').val()

        }, function(data) {
            if (data == 'nomeInvalido') {
                $("#msgbox1").fadeTo(200, 0.1, function() {
                    $(this).html('Nome inválido').addClass('messageboxerror1').fadeTo(900, 1);
                });
            } else if (data != 'emailValido' || data != 'emailRegistado') {
                $("#msgbox1").fadeTo(200, 0.1, function() {
                    $(this).html('Email inválido').addClass('messageboxerror1').fadeTo(900, 1);
                });
            } else if (data == 'passInvalida') {
                $("#msgbox1").fadeTo(200, 0.1, function() {
                    $(this).html('Pass inválida').addClass('messageboxerror1').fadeTo(900, 1);
                });
            } else if (data == 'dadosInvalidos') {
                $("#msgbox1").fadeTo(200, 0.1, function() {
                    $(this).html('Dados inválidos').addClass('messageboxerror1').fadeTo(900, 1);
                });
    /////// } extra, remove
            } else {
                $("#msgbox1").fadeTo(200, 0.1, function() {
                    $(this).html('Registo Efectuado.....').addClass('messageboxok1').fadeTo(900, 1, function() {
                        document.location = 'emprego.php';
                    });
                }); /////// missing ");"
            }
            return false;
        });
    });
}); ////// missing "});"
Sign up to request clarification or add additional context in comments.

3 Comments

if the final else is extra, you should change the last else if to an else.
@vol7ron: the else is not extra, the close paren is.
oh .. I like do do inner comments like /* } // this is extra */ - this makes sense then :) lol
0

You have an extra closing brace at line 26, this:

}
} else {

should be just

} else {

And then you'll want to indent the } else { chunk one more step to make things consistent.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.