0

I'm a beginner with parse and jquery. But for some reason I'm having issues with the most basic thing, which is outputting messages into the console. I've checked my Chrome settings and they're are filtering to all.

I've written the code to simply store email and password FE inputs into parse. If the inputs match the basic validation that I've created, it should display a console message. If the input is invalid, it should display another console message. But for some reason everything I've tried doesn't seem to be working. Here is what my code looks like. https://i.sstatic.net/S42dg.jpg

Thanks for the help. Please let me know if I've left out any information.

index.html

    <div class="modal fade" id="signUp" tabindex="-1" role="dialog" aria-labelledby="signUpLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="signUp-title" id="signUpLabel">Sign Up</h4>

      </div>
      <div class="modal-body">
  <form id = "register-form">
    <div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
      </div>
      <div class="form-group">
    <label for="password">Password</label>
    <input type="password" class="form-control" id="password" placeholder="Password">
     </div>
       <div class="form-group">
    <label for="password2">Confirm Password</label>
    <input type="password" class="form-control" id="password2" placeholder="Confirm Password">
     </div>
      </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Sign Up</button>
      </div>
    </div>
  </div>
</div>

jquery.js

Parse.initialize("xxx", "yyy");

$("#register-form").submit(function(event){ event.preventDefault(); //lets page prevent refresh

var email = $("#exampleInputEmail1"). val(); var password = $("#password"). val(); var password2 = $("#password2"). val();

if ( password == password2) { var user = new Parse.User(); user.set("email", email) user.set("password", password)

user.signUp(null, {success:function(user){
  console.log("Register Succeeded!")
}, error:function(user, error){
  console.log("Registration error:" +error.message);
}   });

}

});

2
  • Your code is fairly long. Pasting it here as text instead of as an image will make other users able to help you much faster. Commented Sep 6, 2015 at 22:41
  • Totally didn't think of doing that. Fixed it now. Thanks for the heads up! Commented Sep 6, 2015 at 22:49

1 Answer 1

1

When i was making your code more readable in my code editor i noticed you have a space between the dot and val() in your variable declarations. You are also missing a semicolon at the end of the first line in the password if statement.

your button also is not inside your form tags and is not of type submit!

Fix those problems and it will work.

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

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.