Я использовал jquery .validate для проверки внешнего интерфейса, он отлично работает для строк, плавающих и раскрывающихся полей. но он не работает с полем date_select. я использовал метод подсказки в rails_form для подсказки dd-mm-yy, есть ли способ проверить date_select? Я также использовал метод подсказки в раскрывающемся списке, но метод jquery .validate там работает нормально ...
<div class="field columns large-3">
<%= form.label :planned_start_date, :class=>"required" %>
<%= form.date_select :planned_start_date, start_year: @project_start_year, end_year: @project_end_year, prompt: { day: 'dd', month: 'mm', year: 'yyyy' }, order: [:day, :month, :year], class: 'select-date' %>
</div>
<div class="field columns large-3">
<%= form.label :planned_end_date, :class=>"required" %>
<%# form.date_select :planned_end_date, start_year: @project_start_year, end_year: @project_end_year, :include_blank => true, order: [:day, :month, :year], class: 'select-date' %>
<%= form.date_select :planned_end_date, start_year: @project_start_year, end_year: @project_end_year, order: [:day, :month, :year], prompt: { day: 'dd', month: 'mm', year: 'yyyy' }, class: 'select-date' %>
</div>
stage. js
$( document ).on('turbolinks:load', function(){
$("#stage-form-validation").validate({
rules: {
"stage[stage]": "required",
"stage[status]": "required",
"stage[responsibility]": "required",
"stage[planned_start_date]": "required", //not working
"stage[planned_end_date]": "required" //not working
},
messages: {
"stage[stage]": "This field is required",
"stage[status]": "This field is required",
"stage[responsibility]": "This field is required",
"stage[planned_start_date]": "This field is required", // not working
"stage[planned_end_date]": "This field is required" //not working
},
errorPlacement: function(error, element)
{
if ( element.is(":radio") )
{
error.appendTo( element.parents('.field') );
}
else
{ // This is the default behavior
error.insertAfter( element );
}
},
submitHandler: function(form) {
form.submit();
}
});
});