[jQuery] Re: [validate] problem of defining custom rules

2009-08-25 Thread david

Let's say i want now to a custom message for a class.
then i would like to define a class firstname
and then define a message for the firstname.
my problem is that instead the error message i want i get the error
message from the required class
the javascript is
$(document).ready(function() {
jQuery.validator.addClassRules("firstname", {
  required: true,
  minlength: 2
});
$("#commentForm").validate({

messages: {
firstname: "Enter your firstname"
}
});
});
and the input is now

Thanks in advance,
David

Here is the whole code


http://www.w3.org/1999/xhtml";>


jQuery validation plug-in - comment form example










$(document).ready(function() {
jQuery.validator.addClassRules("firstname", {
  required: true,
  minlength: 2
});
$("#commentForm").validate({

messages: {
firstname: "Enter your firstname"
}
});
});



#commentForm { width: 500px; }
#commentForm label { width: 250px; }
#commentForm label.error, #commentForm input.submit { margin-left:
253px; }







Please provide your name, email address (won't be 
published)
and a comment

Name (required, at least 2 
characters)


E-Mail (required)



URL (optional)



Your comment (required)











On Aug 25, 8:59 am, Raju  wrote:
> try this ,
>
>  minlength="2" />
>
> Warm Regards,
>
> Mari Raj K,
> Bangalore
> +91 9740765135
>
> On Tue, Aug 25, 2009 at 11:26 AM, david  wrote:
>
> > i played with the example.html from jquery.validate 1.55 and wanted to
> > make a custom rule firstname that is required, with the message please
> > enter a firstname.
> > My changes were in the validate :
> > $("#commentForm").validate({
> >               rules: {
> >                       firstname: "required"
> >                       },
> >               messages: {
> >                       firstname: "Enter your firstname"
> >               }
> >       });
>
> > and then         > minlength="2" />
> > my problem is that it is shown as valid, even i don't enter nothing.
> > i don't know what i am making wrong
>
> > Thanks,
> > David
>
> > This is the code
> >  > "http://
> >www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > http://www.w3.org/1999/xhtml";>
> > 
> > 
> > jQuery validation plug-in - comment form example
>
> > 
>
> > 
> > 
>
> > 
> > 
>
> > 
> > $(document).ready(function() {
> >       $("#commentForm").validate({
> >               rules: {
> >                       firstname: "required"
> >                       },
> >               messages: {
> >                       firstname: "Enter your firstname"
> >               }
> >       });
> > });
> > 
>
> > 
> > #commentForm { width: 500px; }
> > #commentForm label { width: 250px; }
> > #commentForm label.error, #commentForm input.submit { margin-left:
> > 253px; }
> > 
>
> > 
> > 
>
> > 
> >       
> >               Please provide your name, email address (won't
> > be published)
> > and a comment
> >               
> >                       Name (required, at least 2
> > characters)
> >                        > minlength="2" />
> >               
> >                       E-Mail (required)
> >                       
> >               
> >               
> >                       URL (optional)
> >                        > value="" />
> >               
> >               
> >                       Your comment (required) > label>
> >                        > class="required">
> >               
> >               
> >                        > value="Submit"/>
> >               
> >       
> > 
>
> > 
> > 


[jQuery] Re: [validate] problem of defining custom rules

2009-08-25 Thread david

Thank you very much.

On Aug 25, 8:59 am, Raju  wrote:
> try this ,
>
>  minlength="2" />
>
> Warm Regards,
>
> Mari Raj K,
> Bangalore
> +91 9740765135
>
> On Tue, Aug 25, 2009 at 11:26 AM, david  wrote:
>
> > i played with the example.html from jquery.validate 1.55 and wanted to
> > make a custom rule firstname that is required, with the message please
> > enter a firstname.
> > My changes were in the validate :
> > $("#commentForm").validate({
> >               rules: {
> >                       firstname: "required"
> >                       },
> >               messages: {
> >                       firstname: "Enter your firstname"
> >               }
> >       });
>
> > and then         > minlength="2" />
> > my problem is that it is shown as valid, even i don't enter nothing.
> > i don't know what i am making wrong
>
> > Thanks,
> > David
>
> > This is the code
> >  > "http://
> >www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > http://www.w3.org/1999/xhtml";>
> > 
> > 
> > jQuery validation plug-in - comment form example
>
> > 
>
> > 
> > 
>
> > 
> > 
>
> > 
> > $(document).ready(function() {
> >       $("#commentForm").validate({
> >               rules: {
> >                       firstname: "required"
> >                       },
> >               messages: {
> >                       firstname: "Enter your firstname"
> >               }
> >       });
> > });
> > 
>
> > 
> > #commentForm { width: 500px; }
> > #commentForm label { width: 250px; }
> > #commentForm label.error, #commentForm input.submit { margin-left:
> > 253px; }
> > 
>
> > 
> > 
>
> > 
> >       
> >               Please provide your name, email address (won't
> > be published)
> > and a comment
> >               
> >                       Name (required, at least 2
> > characters)
> >                        > minlength="2" />
> >               
> >                       E-Mail (required)
> >                       
> >               
> >               
> >                       URL (optional)
> >                        > value="" />
> >               
> >               
> >                       Your comment (required) > label>
> >                        > class="required">
> >               
> >               
> >                        > value="Submit"/>
> >               
> >       
> > 
>
> > 
> > 


[jQuery] Re: [validate] problem of defining custom rules

2009-08-25 Thread Raju
try this ,




Warm Regards,

Mari Raj K,
Bangalore
+91 9740765135


On Tue, Aug 25, 2009 at 11:26 AM, david  wrote:

>
> i played with the example.html from jquery.validate 1.55 and wanted to
> make a custom rule firstname that is required, with the message please
> enter a firstname.
> My changes were in the validate :
> $("#commentForm").validate({
>   rules: {
>   firstname: "required"
>   },
>   messages: {
>   firstname: "Enter your firstname"
>   }
>   });
>
> and then minlength="2" />
> my problem is that it is shown as valid, even i don't enter nothing.
> i don't know what i am making wrong
>
> Thanks,
> David
>
> This is the code
>  "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> http://www.w3.org/1999/xhtml";>
> 
> 
> jQuery validation plug-in - comment form example
>
> 
>
> 
> 
>
> 
> 
>
> 
> $(document).ready(function() {
>   $("#commentForm").validate({
>   rules: {
>   firstname: "required"
>   },
>   messages: {
>   firstname: "Enter your firstname"
>   }
>   });
> });
> 
>
> 
> #commentForm { width: 500px; }
> #commentForm label { width: 250px; }
> #commentForm label.error, #commentForm input.submit { margin-left:
> 253px; }
> 
>
> 
> 
>
> 
>   
>   Please provide your name, email address (won't
> be published)
> and a comment
>   
>   Name (required, at least 2
> characters)
>minlength="2" />
>   
>   E-Mail (required)
>   
>   
>   
>   URL (optional)
>value="" />
>   
>   
>   Your comment (required) label>
>class="required">
>   
>   
>value="Submit"/>
>   
>   
> 
>
> 
> 


[jQuery] Re: [validate] problem of defining custom rules

2009-08-24 Thread Jörn Zaefferer
"firstname" must refer to the name of a field. There is no field with
that name in your form, just class="firstname".

Jörn

On Mon, Aug 24, 2009 at 4:55 PM, david wrote:
>
> i played with the example.html from jquery.validate 1.55 and wanted to
> make a custom rule firstname that is required, with the message please
> enter a firstname.
> My changes were in the validate :
> $("#commentForm").validate({
>                rules: {
>                        firstname: "required"
>                        },
>                messages: {
>                        firstname: "Enter your firstname"
>                }
>        });
>
> and then         minlength="2" />
> my problem is that it is shown as valid, even i don't enter nothing.
> i don't know what i am making wrong
>
> Thanks,
> David
>
> This is the code
>  www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> http://www.w3.org/1999/xhtml";>
> 
> 
> jQuery validation plug-in - comment form example
>
> 
>
> 
> 
>
> 
> 
>
> 
> $(document).ready(function() {
>        $("#commentForm").validate({
>                rules: {
>                        firstname: "required"
>                        },
>                messages: {
>                        firstname: "Enter your firstname"
>                }
>        });
> });
> 
>
> 
> #commentForm { width: 500px; }
> #commentForm label { width: 250px; }
> #commentForm label.error, #commentForm input.submit { margin-left:
> 253px; }
> 
>
> 
> 
>
> 
>        
>                Please provide your name, email address (won't be 
> published)
> and a comment
>                
>                        Name (required, at least 2 
> characters)
>                         minlength="2" />
>                
>                        E-Mail (required)
>                         />
>                
>                
>                        URL (optional)
>                        
>                
>                
>                        Your comment (required)
>                         class="required">
>                
>                
>                        
>                
>        
> 
>
> 
>