Pocketbook project page refreshing

jquery

#1

Hi!

2 questiones:
1) I don't understand what is "return false" for? As I understood it should make "submit" function return "false" all the time, but for what purpose?
2) 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 === "") {
      $('.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.");
    };
    
    var pass = $('#password').val();
    
    if(pass === "") {
      $('.password-error').text("Please enter a password.");
    } else if (pass.length < 8) {
      $('.password-error').text("Short passwords are easy to guess. Try one with at least 8 characters.");
    };
    
    if(email === "coding@pro.pro") {
      $('email-error').text("This email is already taken.");
    };
});
/*   
return false; */
};

$(document).ready(main);

#2

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