Hi,
I am using botht the
jQuery Validation plugin and the datePicker plugin.
I would like to get the error message for this showing after the calendar icon for the datePicker plugin. I have tried this and cannot get it to work and so far not found a solution on any website I have checked.
jQuery Validation code
- $(document).ready(function() {
- $("#adminform").validate({
- submitHandler: function(form) {
- SubmittingForm();
- },
- rules: {
- date: {
- required: true,
- date: true
- }
- },
- errorPlacement: function(error, element) {
- if(element.type == 'input') {
- error.insertAfter(element.sibling(a));
- }
- else {
- error.insertAfter(element);
- }
- }
- });
- });
Trying the sibling thing was my last probably silly attempt at getting this working lol.
HTML output when the field fails validation
- <fieldset>
- <legend>Update Date</legend>
- <label for="date" class="admin">Date of Run: </label>
- <input type="text" class="date-pick dp-applied error" size="7" value="" name="date" id="date">
- <label for="date" generated="true" class="error">This field is required.</label>
- <a title="Choose date" class="dp-choose-date" href="#">Choose date</a>
- </fieldset>
As you can see the label for the error is placed inbetween the input field and <a> for the calendar image. Does anyone have idea how to get this label to show after the <a>.
Cheers,
Bala.