vivek
vivek

Reputation: 57

Error message not get cleared while clicking the reset button

I am using jquery.validate.js file to validate an input form, It works fine, my problem is the error messages are not get cleared while clicking the reset button in the form.

how to get clear the form?

here is the code

 <script type="text/javascript" src="js/jquery.js"></script>

 <script type="text/javascript" src="js/jquery.validate.js"></script>


  javascript function

      $(document).ready(function(){        

        $("#demo-form").validate({    
          rules: {
            name: "required",
            address: "required",
       }

HTML Code

<div><input type="text" id="name" name="name" /></div>

<div><input type="text" id="address" name="address" /></div>

<div> <input type="submit" id="submit" value="Validate!" />
      <input type="reset" id="reset" value="Reset" />   

Upvotes: 0

Views: 1804

Answers (2)

Starx
Starx

Reputation: 78971

Basically, when you click the reset button. It will be responsible for clearing the fields, not the label. Normally, jquery validate plugin, keeps its validation messages in labels. So in order to clear them, use

$('label.error').remove();

call this on the click of reset button where it is needed.

Upvotes: 1

abhiasawa
abhiasawa

Reputation: 1340

Try hiding them by calling CSS hide property on your error DIV's when you press reset button

Upvotes: 0

Related Questions