Pocketbook project page refreshing


#1


I can't prevent page from refreshing. The example page doesn't refresh. What should be done?


var main = function() {
  $('form').submit(function() {
    var firstName = $('#first').val();
    if(firstName === "") {
      $('p.first-name-error').text('Please enter your first name.');
    }
    var LastName = $('#last').val();
		if(LastName === "") {
      $('p.last-name-error').text('Please enter your last name.');
    };
    var email = $('#email').val();
    if(Email === "") {
      $('p.email-error').text('Please enter your email address.');
    };
    var password = $('#password').val();
    if(Password === "") {
      $('p.password-error').text("Please enter a password.");
    };
    if(password.length < 8){
      $('p.password-error').text("Short passwords are easy to guess. Try one with at least 8 characters.");
    };
    return false;
  });
};

$(document).ready(main);


#2

I figured it out on my own what was the issue! it was in the capital letters,i set my variables with LowerCase letters, and i put in my if statements upper case ones! so now everything is working just fine!

var main = function() {
  $('form').submit(function() {
    var firstName = $('#first').val();
    if(firstName === "") {
      $('.first-name-error').text('Please enter your first name.');
    }
    var LastName = $('#last').val();
		if(LastName === "") {
      $('.last-name-error').text('Please enter your last name.');
    };
    var email = $('#email').val();
    if(email === "") {
      $('.email-error').text('Please enter your email address.');
    } else if(email === 'loanfigueiredo@gmail.com'){
      $('.email-error').text('Sorry,This email is already taken');
    }
    
    var password = $('#password').val();
    if(password === "") {
      $('.password-error').text("Please enter a password.");
    };
    if(password.length < 8){
      $('.password-error').text("Short passwords are easy to guess. Try one with at least 8 characters.");
    };
    return false;
  });
};

$(document).ready(main);

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.