I'm so sorry but i really don't understand javascript, i use your script to simplify me the validation process of my form. I try many solution but no one works, can you help me ?
I just want to put the error for the #TitleNews input in the #TitleError div... I have find and modify that, but i don't know how to precise the ID and not the form type (:input) errorPlacement: function(error, element) { if ( element.is(":input")) error.appendTo( "#TitleError" ); else if ( element.is(":checkbox") ) error.appendTo ( element.next() ); else error.appendTo( element.parent().next() ); } With that all my errors are going to the div#TitleError of course.... because i have only input elements in my form. Thanks for wasting time with me. On 20 août, 14:49, "Jörn Zaefferer" <[EMAIL PROTECTED]> wrote: > Nope, that isn't supported. Though its easy enough to implement that > based on errorPlacement. > > Jörn > > 2008/8/20 PanPan <[EMAIL PROTECTED]>: > > > > > Thx for your response but i already watch the doc. Can we specify > > location without function ? ex: > > > $(document).ready(function(){ > > $("#News").validate({ > > rules: { > > TitleNews: {required: true,minLength: 10}, > > IntroNews: {required: false,minLength: 150}, > > ContentNews: {required: true,minLength: 200}, > > TagsNews: {required: false,minLength: 5} > > }, > > > messages: { > > TitleNews: {required: "<img src=\"style/imgs/action_stop.gif\" > > alt=\"\" />Merci de rentrer un titre<img src=\"style/imgs/ > > action_stop.gif\" alt=\"\" />", > > minlength: "Votre titre doit contenir au moins > > 10 caractères !"}, > > IntroNews: {minlength: "L'intro doit contenir au moins 150 > > caractères !"}, > > ContentNews: { required: "Merci de rentrer le contenu de votre > > news !", > > minlength: "Le contenu de votre news > > doit être au moins de 200 caractères !"}, > > TagsNews: {minlength: "Le contenu des tags doit être d'au moins > > 5 caractères !"} > > }, > > > errorPlacement : { > > IntroNews : #TitleError, > > IntroNews : #IntroError, > > ContentNews : #ContentError, > > TagsNews : TagsError} > > }); > > }); > > > Thanks ! > > > On 20 août, 12:49, "Jörn Zaefferer" <[EMAIL PROTECTED]> > > wrote: > >> Documentation for the various options, including errorPlacement, are > >> herehttp://docs.jquery.com/Plugins/Validation/validate#toptions > > >> There are also various demos available, eg. the Remember The Milk > >> Registration form, which uses > >> errorPlacement:http://docs.jquery.com/Plugins/Validation#Demos > > >> Jörn > > >> 2008/8/19 PanPan <[EMAIL PROTECTED]>: > > >> > Hi everyone, i'm having trouble with the jQuery Validate plugin. I > >> > easily find how to validate my form, but i would like to specify > >> > location for every error message the validate plug-in send. But i > >> > don't find, i think it's withe the option "errorPlacement" but i don't > >> > know how to use it exactly. > > >> > Here is my code : > > >> > $(document).ready(function(){ > >> > $("#News").validate({ > >> > rules: > >> > { > >> > TitleNews: {required: > >> > true,minLength: > >> > 10}, > >> > IntroNews: {required: > >> > false,minLength: > >> > 150}, > >> > ContentNews: {required: > >> > true,minLength: 200}, > >> > TagsNews: {required: > >> > false,minLength: 5} > >> > }, > >> > messages: > >> > { > >> > TitleNews: > >> > { required: "<img src=\"style/imgs/ > >> > action_stop.gif\" alt=\"\" />Merci de rentrer un titre<img src=\"style/ > >> > imgs/action_stop.gif\" alt=\"\" />", > >> > minlength: "Votre > >> > titre doit contenir au > >> > moins 10 caractères !" > >> > }, > >> > IntroNews: {minlength: > >> > "L'intro doit > >> > contenir au moins 150 caractères !"}, > >> > ContentNews: > >> > { required: "Merci de rentrer le > >> > contenu de votre news !", > >> > minlength: "Le > >> > contenu de votre news > >> > doit être au moins de 200 caractères !" > >> > }, > >> > TagsNews: {minlength: "Le > >> > contenu des > >> > tags doit être d'au moins 5 caractères !"} > >> > } > >> > }); > >> > }); > > >> > And the HTML : > > >> > <form action="toto.php" method="POST" name="News" id="News"> > >> > <label for="TitleNews">Titre de la news*</label> > >> > <input name="TitleNews" class="required" minlength="5" /> > >> > <div id="TitleError"></div> > >> > <br /> > >> > <label>BBCode<br /><i>Pour l'intro.</i></label> > >> > <div class="BoxToolbar"> > >> > <div id="hautdroit"></div> > >> > <div id="hautgauche"></div> > >> > <div id="contenu"> > >> > <?php AfficheToolbarBBCode("IntroNews") ;?> > >> > </div> > >> > <br /> > >> > </div> > >> > <label for="IntroNews">Intro de la news</label> > >> > <textarea name="IntroNews" id="IntroNews" style="height: > >> > 150px;"></textarea> > >> > <div id="IntroError"><img src="style/imgs/action_stop.gif" > >> > alt="" />Intro Error !! <img src="style/imgs/action_stop.gif" alt="" / > >> >></div> > >> > <br /> > >> > <label>BBCode<br /><i>Pour le contenu.</i></label> > >> > <div class="BoxToolbar"> > >> > <div id="hautdroit"></div> > >> > <div id="hautgauche"></div> > >> > <div id="contenu"> > >> > <?php AfficheToolbarBBCode("ContentNews") ;?> > >> > </div> > >> > <br /> > >> > </div> > >> > <label for="ContentNews">Contenu / suite de la news*</label> > >> > <textarea name="ContentNews" id="ContentNews"></textarea> > >> > <div id="ContentError"><img src="style/imgs/action_stop.gif" > >> > alt="" />Contenu Error !! <img src="style/imgs/action_stop.gif" > >> > alt="" /></div> > >> > <br /> > >> > <label for="Tags">Tags</label> > >> > <input name="TagsNews"> > >> > <div id="TagsError"><img src="style/imgs/action_stop.gif" > >> > alt="" />Tags Error !! <img src="style/imgs/action_stop.gif" alt="" / > >> >></div> > >> > Entrer un ou plusieurs tags, separé par une virgule. <i>Les > >> > tags sont des mots-clés utilisés pour décrire votre news. > >> > Par exemple, si votre news contient des photos de plages > >> > bretonnes, vous pouvez indiquer les tags suivants : > >> > photo, plage, Bretagne.</i> > >> > <br /> > >> > <br /> > >> > <div class="buttons"> > >> > <a href="#"><img src="style/imgs/sauvegarde.jpg" alt="" /> > >> > Sauvegarder</a> > >> > </div> > >> > <div class="LastSave"> > >> > Derniere sauvegarde le 11 Novembre 2008 à 18h30. > >> > </div> > >> > <br /> > >> > <br /> > >> > <div class="buttons"> > >> > <button type="submit"> > >> > <img src="style/imgs/send.jpg" alt="" />Envoyer > >> > </button> > >> > </div> > >> > <div class="buttons"> > >> > <a href="#apercu" onclick="Apercu();"><img src="style/imgs/ > >> > preview.jpg" alt="" />Apercu</a> > >> > </div> > >> > <br /><br /><br /> > >> > </form> > > >> > Thanks !!!!