0

Hello everyone I'm trying to creating a login function using parse.com and javascript for my website using a form. However I keep on getting the Uncaught ReferenceError: myfunction is not defined error when I test it. Any help would be greatly appreciated.

Thanks guys I have added the quotation marks which have removed the Uncaught ReferenceError: myfunction is not defined error. But I'm now getting an Uncaught ReferenceError: $ is not defined error. How would I go about removing this error?

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Sign Up</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, intial-scale=1.8" />
    <script type="text/javascript" src="//www.parsecdn.com/js/parse-1.2.16.min.js"></script>
    <script type="text/javascript">
            function  myfunction() {
                var user = new Parse.User();
                user.set("FirstName", $(#signup-upFirstName).val());
                user.set("Surname", $(#signup-Surname).val());
                user.set("EmailAddress", $(#signup-Confirmemailaddress).val());
                user.set("Password", $(#signup-ConfirmPassword).val());

                user.signUp(null, {
                    success: function (user) {
                        // Hooray! Let them use the app now.
                    },
                    error: function (user, error) {
                        // Show the error message somewhere and let the user try again.
                        alert("Error: " + error.code + " " + error.message);
                    }
                });
            };

        </script>
    <style type="text/css">
        .auto-style1 {
            width: 156px;
        }
    </style>
</head>
<body>
    <div>

    <form>
       First Name: <input id="signup-FirstName" type="text" placeholder="Firstname"required="" />
       Surname: <input id="signup-Surname" type="text" placeholder="Surname" required=""/>
       Email Address:<input id="signup-EmailAddress" type="text" placeholder="EmailAddress" required=""/>
       Confirm Email Address: <input id="signup-Confirmemailaddress" type="text" placeholder="confirmemailaddress" required =""/>
       Password: <input id="signup-password" type="password" placeholder="password" required="" />
       Confirm Password: <input id="signup-ConfirmPassword" type="password" placeholder="confirmpassword" required="" />
       <input type="submit" onclick="myfunction();" value="Next" />
    </form>
    </div>



</body>
</html>
1
  • Could you set up a jsfiddle.net? Commented Jan 14, 2014 at 17:37

2 Answers 2

1

Your function has several syntax errors, so parsing stops and the function is never defined.

 $(#signup-upFirstName).val());

You're missing quotation marks around "#signup-upFirstName" and your other jQuery selectors. jQuery selectors are just regular strings, they require quotes.

Sign up to request clarification or add additional context in comments.

2 Comments

Plus he is missing the jQuery <script> lib reference
@FelipeKM That would yield a different error down the road when the function is actually invoked when that button is clicked...
0

You're missing quotes in your jQuery selectors.

function  myfunction() {
                var user = new Parse.User();
                user.set("FirstName", $('#signup-upFirstName').val());
                user.set("Surname", $('#signup-Surname').val());
                user.set("EmailAddress", $('#signup-Confirmemailaddress').val());
                user.set("Password", $('#signup-ConfirmPassword').val());

                user.signUp(null, {
                    success: function (user) {
                        // Hooray! Let them use the app now.
                    },
                    error: function (user, error) {
                        // Show the error message somewhere and let the user try again.
                        alert("Error: " + error.code + " " + error.message);
                    }
                });
            };

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.