Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to validate email id and password and password should contain lowercase,uppercase and minimum one character and both fields should be inline?

   <!DOCTYPE html> 
    <html>
    <head>
    <title>Login Page</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet"href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
    </script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">
    </script>
    </head>
    <body >     
    <div id="divi" height="100"> 
    <form class="form-inline" role="form">
    <div class="form-group" >
    <label class="sr-only" for="em">Email:</label>
    <input type="email" id="em" placeholder="Enter email" required >
    </div>
    <div class="form-group" >
    <label class="sr-only" for="pwd">Password:</label>
    <input type="password"  id="pwd" placeholder="Enter password" required>
    </div>
    <button type="button" class="btn btn-primary">Login</button>
    </form>
    </div>
    </body>
    </html>

Hi please help me to validate the user id with email id and the password should contain uppercase lowercase and atleast one character?

like image 677
Sankar Karthi Avatar asked Nov 09 '22 22:11

Sankar Karthi


1 Answers

Follow this guide:

http://www.webdesignerdepot.com/2012/01/password-strength-verification-with-jquery/

Here is an example of the Jquery code:

 //validate letter
 if ( pswd.match(/[A-z]/) ) {
     $('#letter').removeClass('invalid').addClass('valid');
} else {
     $('#letter').removeClass('valid').addClass('invalid');
}

//validate capital letter
if ( pswd.match(/[A-Z]/) ) {
    $('#capital').removeClass('invalid').addClass('valid');
} else {
    $('#capital').removeClass('valid').addClass('invalid');
}

//validate number
if ( pswd.match(/\d/) ) {
    $('#number').removeClass('invalid').addClass('valid');
} else {
    $('#number').removeClass('valid').addClass('invalid');
}

[A-z] This expressions checks to make sure at least one letter of A through Z (uppercase) or a through z (lowercase) has been entered

[A-Z] This expressions checks to make sure at least one uppercase letter has been entered

\d This will check for any digits 0 through 9

like image 66
Badrush Avatar answered Nov 14 '22 21:11

Badrush