how to validate form in jquery this code not working :     $(document).ready(function(){
    
      var name = $('#signup-name').val();
      var email = $('#signup-email').val();
      var password = $('#signup-password').val();
      var email_regex = new RegExp(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
      var pass_regex = new RegExp(/^(?=.[0-9])(?=.[!@#$%^&])[a-zA-Z0-9!@#$%^&]{7,15}$/);
    
      
      $('#signup-form').on('submit',function(e){
        e.preventDefault();
    
    
        if (validate()) {
    
          $.ajax({
            type : 'post',
            url : 'signup',
            data :{email : email, password : password, name: name},
          });
    
        }else {
          return false;
        };
    
    
    
    
    
      });
    
    
      function validate() {
            // name cheak here
        if (name.length == "") {
          $('.nameerror').html("Name field required !");
          return false;
        }else if (name.length =< 3) {
          $('.nameerror').html("Name Should be greater than 3");
          return false;
    
        };
             // email cheak here
    
        if (email.length == "") {
          $('.emailerror').html("Email field required !");
          return false;
        }else if (!email_regex.test(email)) {
          $('.emailerror').html("Please enter correct email.");
          return false;
        };
    
         // password cheak here
    
     if (password.length == "") {
       $('.passerror').html("password field required !");
       return false;
     }else if (!pass_regex.test(password)) {
            #('.passerror').html("Minimum eight characters, at least one letter and one number:");
            return false;
     };
    
    };
    
    
    
    });




**i want to send my form data to server by validating in jquery or javascript but my form data not validated ,i don't know why? please help me fast**



//.........................................nothing here dude..............................................uiygfiuyfiiiiiiiiuuuuyiugyuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiui//