nic
nic

Reputation: 939

how to Reset error message using jquery validation?

i want to remove or clear error message and reset jquery validation when i am click on cancel button.

here i have given my code :

$(document).ready(function() {
    var validator = $("#loginForm").validate({
        messages: {
            email: {
                required: "Please enter email.",
                email: "Please enter a valid email."
            },
            password: "Please enter password."
        }
    });

     <form name="loginForm" id="loginForm" method="post" action="javascript:login();">
                        <div class="login_contain_div">
                             <div id="login_errors" class="errors"></div>
                             <div class="login_contain_inner">

                                  <span style="font-size: 20px; font-weight: lighter;">Email</span>
                                  <input type="text" id="email" name="email" class="inputbg required email" />

                                  <br/>
                                  <span style="font-size: 20px; font-weight: lighter;">Password:</span>
                                  <input type="password" id="password" name="password" class="inputbg required" />
                             </div>
                             <div class="login_button_area">

                                  <input type="submit" id="login_submit" class="login_greenbtn button_float_left login_btn_width" name="submit" value="Ok" style="cursor: pointer;" />
                                  <a class="ptr login_greenbtn button_float_right login_btn_width" onClick="$('#cboxClose').click();">Cancel</a>
                             </div>
                        </div>
                   </form>

Upvotes: 0

Views: 2396

Answers (1)

Suave Nti
Suave Nti

Reputation: 3747

use resetForm()

 $(".cancel").click(function() {
   validator.resetForm();
 )};

Upvotes: 2

Related Questions