0
votes

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>
2
Could you set up a jsfiddle.net?felipekm

2 Answers

1
votes

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.

0
votes

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);
                    }
                });
            };