Jump to content

Jquery Validate - Custom error message help


herghost

Recommended Posts

Hi all,

 

I am having some problems with the jquery validate plugin.

 

I am putting my error messages in a div, however when using the min attribute the error message is repeated everytime a keystroke is made.

 

For example, my password field requires a min of 8 characters, so the error message appears 8 times!

 

This is what I am using:

<script>
$(document).ready(function(){
$("#registerForm").validate({
  rules: {
		username: {
			required: true,


		},
		password: {
			required: true,
			minlength: 8
		},

		email: {
			required: true,
			email: true,
			}

		},
		errorPlacement: function(error, element) {
                 error.appendTo('#err');
             }



  });});
  
</script>

 

and to display

<div id="err">
</div>

 

and css

label.error {

    border:solid 1px #f00;
background:#F00;
color:#FFF;
padding:4px;
text-align:center;
font-size:14px;		
    }

 

Any help would be much appreciated :)

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.