How to solve the problem when using jquery datepicker and checking at the same time

When I used a datepicker with a trigger icon so that users can select a date by clicking on this icon or enter directly into the text field (txtDate), I also used jquery validation to require that the text field is not empty. But when the user submits a form with an empty text field (txtDate.Text = ""), the trigger confirmation error message is the trigger on the right. Could you tell me a solution? Thank you very much!

+3
source share
1 answer
$('#some_form').validate({
  rules: {...},
  messages: {...},
  errorPlacement: function(error, element) { //solve you problem
    var trigger = element.next('.ui-datepicker-trigger');
    error.insertAfter(trigger.length > 0 ? trigger : element);
  }
});
+2
source

Source: https://habr.com/ru/post/1739076/


All Articles