tirenweb
tirenweb

Reputation: 31749

First steps with Javascript: trying to debug

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

Upvotes: 1

Views: 123

Answers (5)

codaddict
codaddict

Reputation: 455460

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

Upvotes: 0

Aleksandar Vucetic
Aleksandar Vucetic

Reputation: 14953

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

Upvotes: 0

Randy the Dev
Randy the Dev

Reputation: 26740

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?

Upvotes: 1

powtac
powtac

Reputation: 41080

$(document).ready(function() {

was missing at the beginning

Upvotes: 0

Ben Everard
Ben Everard

Reputation: 13804

$(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.

Upvotes: 5

Related Questions