Login and Register page is rendering twice

Whenever I fill username and password in my login page I am again
redirected to the login page.However the url of the page changes to http://localhost:3000/login?username=Harshit&password=harshit
where Harshit and harshit is the login username and password
respectively.The username and password in the input fields though remain
unpopulated.If I enter the username and password again then I am
allowed to enter the webapp.The same thing happens with the register
page.I am not able to register in the first attempt.

Also the jquery validation rules that are set do not show any effect
the first time I enter the fields to login and register page.However
they come into effect the second time I enter the fields in login and
register page.

Here is the HTML code for login page:

<template name="login">
    <div class="login-form">
        <form class="login">
            <p>Username: <input type="text" name="username" id='usernameL' placeholder='Username' required></p>
            <br>
            <p>Password: <input type="password" name="password" id='passwordL' placeholder='password' required></p>
            <p><button type="submit" class="btn btn-primary">Let me in</button></p>
            <br>
            <p>Don't have an account</p>
            <br>
            <h3><a href='{{pathFor route="home"}}'>Register</a></h3>
        </form>
    </div>
</template>

The home page is the register page.
Here is the js code :

Template.login.onRendered(function() {
    $('.login').validate({
        submitHandler: function(event) {

            var username = document.getElementById('usernameL').value;
            var password = document.getElementById('passwordL').value;
            Meteor.loginWithPassword(username, password, function(error) {
                if (error) {
                    alert(error.reason);
                } else {
                    Router.go("posts");
                }
            });
        }
    });
});

The code for routerjs:

Router.route('/login', {
    template:'login',
    name:'login'
});