Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#2561 closed enhancement (invalid)

[validate] custom errorPlacement

Reported by: sniffer Owned by: joern
Priority: minor Milestone:
Component: plugin Version:
Keywords: validation errorPlacement Cc:
Blocked by: Blocking:


Text below taken from http://groups.google.com/group/jquery-en/browse_thread/thread/55497acab96f23ac#

I have created a test page at Jörn's request - this can be found here: http://snifferweb.com/Misc/jquery/calendartest.php

Let me know if you need any more info.

Thanks for your time



I've been using the validation plugin quite happily (it's a great plugin), but I've just tried to implement a datepicker on one of my forms and I cannot get the error to show correctly.

My original markup is like this:

<label for="title_publication_date">Publication date:</label> <input id="title_publication_date" name="title_publication_date" type="text" /> <span class="status"></span>

But the datepicker (which is part of jquery UI) amends the markup on the fly to produce:

<label for="title_publication_date">Publication date:</label> <span class="datepicker_wrap">

<input id="title_publication_date" class="hasDatepicker" type="text" name="title_publication_date"/> <img class="datepicker_trigger" title="..." alt="..." src="../../Common/Images/calendar.gif"/>

</span> <span class="status"></span>

I've got the following validation rules on this input:

title_publication_date: { required: true, date: true }

Unfortunately, if I leave the input field blank the validation doesn't appear to run - or I probably should say - the validation runs, but I can't see the error message.

I've tried amending the errorPlacement as follows (see 2nd else if statement), but this doesn't seem to work:

errorPlacement: function(error, element) {

if ( element.is(":radio") )

error.appendTo( element.parent().next().next('span') );

else if ( element.is(":checkbox") )

error.appendTo ( element.next('span') );

else if ( element.is(":input" &&


error.appendTo ( element.parent().next('span') );


error.appendTo( element.next('span') );


Is there any way that I can target the "#title_publication_date" input specifically and have a cusotm errorPlacement for it?

Thanks for your time


Change History (2)

comment:1 Changed 15 years ago by joern

Owner: set to joern
Summary: validation plugin: custom errorPlacement[validate] custom errorPlacement

comment:2 Changed 15 years ago by joern

Resolution: invalid
Status: newclosed

This works fine on your testpage:

if ( element.is("#textdate1") )
	error.appendTo ( element.parent().next('span') );
	error.appendTo( element.next('span') );

I therefore consider this ticket invalid.

Note: See TracTickets for help on using tickets.