Speed up development with full-stack environments for every branch.

Learn More

How to use jQuery-validation - Simple login form

18414 Runs 75205 Views 28996 Copies


gtsolutions 373

published 4 years ago

        <meta charset="utf-8">
        <title>jQuery Validation Plugin Examples</title>

        <!-- Bootstrap CSS used for styling the demo pages-->
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/style.css">

        <!-- basic validation of a login form -->
        <form class="form" id="example1">
            <div class="form-group">
                <label>Basic login form example</label>
            <div class="form-group">
                <label for="example1-email">Email address</label>
                <input type="email" class="form-control" id="example1-email" name="example1-email" placeholder="Enter email">
            <div class="form-group">
                <label for="example1-password">Password</label>
                <input type="password" class="form-control" id="example1-password" name="example1-password" placeholder="Password">
            <button type="submit" class="btn btn-primary">Submit</button>

        <!-- Load jQuery and jQuery-Validate scripts -->
        <script src="js/jquery.js"></script>
        <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
            // When the document is ready
            $(document).ready(function () {
                //validation rules
                //by default it will append a <label class="error> element to the invalid input
                //and will add a "error" class to the input
                    rules: {
                        "example1-email": {
                            required: true,
                            email: true
                        "example1-password": {
                            required: true,
                            minlength: 5
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).