pls am not getting things right with this my code
i want to alert the user when there is no input made in the FIRSTNAME, LASTNAME, USERNAME
BUT i am done with the EMAIL and PASSWORD SECTION
SOMEONE PLS HELP ME WITH THIS CODE PLS...

<!DOCTYPE html>
<html>
    <head>
        <title>Page Title</title>
        <link href="Signupvalidation.css" rel="stylesheet">
        <script src="Signup.js"></script>
    </head>
    <body>
        <form name="Sform">
            <h2>USER SIGN UP</h2>
          <input type="text" id="_Firstname" name="Fisrtname" placeholder="Firstname" />
          <input type="text" id="_Lastname" name="Lastname" placeholder="Lastname" />
          <input type="text" id="_Username" name="Username" placeholder="Username" />
          <input type="Email" id="_Email" name="Email" placeholder="Eg:Larry@Aol.com"/>
          <input type="password" id="_Password" name="Password" placeholder="Password"/>
          <input type="password" id="_Confirmpassword" name="ConfirmPassword" placeholder="Confirm Password"/>
          <button onclick="return(validate())">Sign Up</button><br>
         <p>Already Registered?<a href="#" target="_self"> Login</a></p><br>
         </form> 
    </body>
</html>

<!--  MY JAVASCRIPT -->

function validate() {
    var Firstname = document.getElementById("_Firstname").value;
    if ( Firstname == "" || Firstname < 6){
        if( Firstname == "" ){ 
            alert( "Please provide your Firstname!" ); 
            Sform._Firstname.focus();
            return false;
        }
        if ( Firstname < 2 ){ 
            alert( "Please Name must be at least 3 characters!" ); 
            Sform._Firstname.focus();
            return false;
        }
    }   

    var Lastname = document.getElementById("_Lastname").value;
    if ( Lastname == "" || Lastname < 6){
        if( Lastname == "" ){ 
            alert( "Please provide your Lastname!" ); 
            Sform._Lastname.focus();
            return false;
        }
        if ( Lastname < 2 ){ 
            alert( "Please Name must be at least 3 characters!" ); 
            Sform._Lastname.focus();
            return false;
        }
    }    

    var Username = document.getElementById("_Username").value;
    if ( Username == "" || Username < 6){
        if( Username == "" ){ 
            alert( "Please provide your Username!" ); 
            Sform._Username.focus();
            return false;
        }
        if ( Username < 6 ){ 
            alert( "Please Username must be at least 6 characters!" ); 
            Sform._Username.focus();
            return false;
        }
    }   

    var Email= document.getElementById("_Email").value;
    var filter= /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if( Email == "" || !filter.test(Email)){
         if( Email == ""){
         alert("Please provide your Email!");
         Sform._Email.focus();
         return false;
        }

         if(!filter.test(Email)){
         alert("Please provide a valid Email!");
         Sform._Email.focus();
         return false;
        }
    }

    var Password = document.getElementById('_Password').value;
    var Confirmpassword = document.getElementById('_Confirmpassword').value; 
    var letterlow = /[a-z]/; 
    var letterUp= /[A-Z]/; 
    var number = /[0-9]/; 

    if(Password == "" || Password.length < 6 || !letterlow.test(Password) || letterUp.test(Password) || !number.test(Password) || Password !=Confirmpassword ) { 
         if(Password == "" ){ 
         alert("Please provide a password!");
         Sform._Password.focus();
         return false;
        }
         if(Password.length < 6){
         alert("Please password must be longer than 6 characters!");
         Sform._Password.focus();
         return false;
        }
          if(!letterlow.test(Password) || !letterUp.test(Password) || !number.test(Password)){ 
          alert("Please Password must Include at least (1 uppercase, 1 lowercase and 1 digit)");
          Sform._Password.focus();
          return false;
        }
         if(Password != Confirmpassword){ 
         alert("Please passwords do not match!");
         return false;
        }
    }
        return (true);
}

Where it says Firstname < 6 needs to be Firstname.length < 6

Same goes for Lastname and Username. Those variables are strings so will error trying to evaluate them to a number

Well i can help you with a jquery code.

$(#_firstname).on('keyup', 
function () {
var firstname = $(#_firstname).val();
If ( firstname == '') {
alert("Please first name must not be empty");
}
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.