I have a register form , in which when a already registered email gets entered , it shows a error message with a login link, when clicked on login link it redirects to login page, here I want to prefill the the email field with that user email. I tried different methods upon it, nothing is working to fill the user email in href link in the jQuery validate messages.
I would appreciate some help.
form:
<form id="signupForm" method="post" class="login-form text-center" action="/accounts/register/"> <div class="form-group"> <input type="email" id="email" class="field__input" placeholder="Email ID" name="email"> </div> </form>
jquery-validate file:
<script type="text/javascript"> $ .validator.setDefaults( { submitHandler: function () { return true; } } ); $ ( document ).ready( function () { $ ( "#signupForm" ).validate( { rules: { email: { required: true, remote: {url: "{% url 'check_email' %}",type:'get'} } }, messages: { email: { required: "Please enter your Email address", remote: "An account with that Email ID already exists, <a href='/accounts/login/?email=|--user email goes here--|'>login</a>" } }, errorElement: "em", errorPlacement: function ( error, element ) { // Add the `help-block` class to the error element error.addClass( "help-block" ); if ( element.prop( "type" ) === "checkbox" ) { error.insertAfter( element.parent( "label" ) ); } else { error.insertAfter( element ); } }, highlight: function ( element, errorClass, validClass ) { $ ( element ).parents( ".form-group" ).addClass( "has-error" ).removeClass( "has-success" ); }, unhighlight: function (element, errorClass, validClass) { $ ( element ).parents( ".form-group" ).addClass( "has-success" ).removeClass( "has-error" ); } } ); } ); </script>