Navigation

    ask avan logo
    • Register
    • Login
    • Search
    • Categories
    • Unsolved
    • Solved
    1. Home
    2. willaeng
    W
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Groups 0

    willaeng

    @willaeng

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    willaeng Follow

    Latest posts made by willaeng

    • Javascript Registration Form Validation

      Sorry I have been really struggling with this. I have more codes, but can't get pass the username yet. It wouldn't even send an alert. Below is just a portion of what I have. Thanks in advance. I just need suggestion on how to get first field (username) to validate and I can go from there.

      function validateForm() {
      
          var userId = document.myForm.userName.value;
          var password = document.myForm.passwordOne.value;
         var passwordVerify = document.myForm.passwordTwo.value;
          var fName = document.myForm.firstName.value;
          var lName = document.myForm.lastName.value;
          var emailAdd = document.myForm.email.value;
          var phone = document.myForm.phonenumber.value;
      
          if (uName(userId)) {
              if (validatePassword(password)) {
                  if (passwordCheck(password, passwordVerify)) {
                      if (onlyLetters(fName)) {
                          if (onlyLetters(lName)) {
                              if (validateEmail(emailAdd)) {
                                  if (phonenumber(phone)) {
                                  }
                              }
                          }
                      }
                  }
              }
          }
          return false;
      }
      
      
      function uName(userId){
      
          var userId_len = userId.value.length;
          var alphaNumber = /^[\w ]+$/;
      
          if (userId_len == 0)
          {
              alert("User Id should not be empty");
              userID.focus();
              return false;
          }
          else if (userId.value.match(alphaNumber)) {
              return true;
          }
          else {
              alert("User Id should be alphanumeric");
              userId.focus();
              return false;
          }
          }
      posted in Javascript + jQuery
      W
      willaeng