tags:

views:

51

answers:

5

Hi,

i have added to the beginning of my code this great script below.

<script type="text/javascript">

alert("pippo");


</script>

And it works: when i load the page it shows a small window with "pippo".

If i I add this below after the alert:

    $(document).ready(function()
    // validate signup form on keyup and submit


    $("#foo").validate({
        rules: {
            'telephone[number]': {
        number: true
            }
        },
        messages: {
            'telephone[number]': "Please enter a telephone number"

        }
    });
});

and reload the page it doesn't show "pippo" any more..Why?

Regards

Javi

+5  A: 
$(document).ready(function() { // <-- missing opening {
    // validate signup form on keyup and submit


    $("#foo").validate({
        rules: {
            'telephone[number]': {
        number: true
            }
        },
        messages: {
            'telephone[number]': "Please enter a telephone number"

        }
    });
});

Look at the first line, works fine when fixed.

ILMV
A: 
$(document).ready(function() {

was missing at the beginning

powtac
No, it's there, it's just indented wrong and missing the `{` as [ILMV pointed out](http://stackoverflow.com/questions/3785624/first-steps-with-javascript-trying-to-debug/3785642#3785642).
T.J. Crowder
Check this out http://stackoverflow.com/posts/3785624/revisions
powtac
+1  A: 

It's because you must have some invalid code which is failing to be parsed by the engine, first step: do you have jQuery loaded?

Andrew Dunn
A: 

You have a syntax error, missing { after function(). Also, make sure that you have included jquery.

vucetica
A: 

That is because your program has a syntax error of missing { after $(document).ready(function()

codaddict