$$(document).on('page:init', '.page[data-name="signup"]', function(e) {

  $(document).off("click", "#signup_button").on("click", "#signup_button", function(e) {

  console.log('app signup ready')

    e.preventDefault();

    let email = $("#reg_email").val();

    let password = $("#reg_password").val();

    let confirmpwd = $("#reg_confirmpwd").val();

    let firstname = $("#reg_firstname").val();

    let lastname = $("#reg_lastname").val();

    let errMsg = "";

    let req = {

      email,

      password,

      confirmpwd,

      firstname,

      lastname

    };

    if (email && password && confirmpwd && firstname && lastname) {

      if (confirmpwd === password) {

        signup(req);

      } else {

        app.dialog.alert("Passwords do not match", "Sign Up Errors");

      }

    } else {

      app.dialog.alert("All fields are required", "Sign Up Errors");

    }

  });

});