我已经在这个问题上工作了一天并尝试了各种解决方案,但它们似乎都没有起作用。
<%= form_tag("/report", method: "post", id: 'report-form') do |f|%>
<div class="form-group">
<%= radio_button_tag :report_reason, 1 %>
<%= label_tag :report_reason_l, 'Inappropriate Photo' %>
</div>
<div class="form-group">
<%= radio_button_tag :report_reason, 2 %>
<%= label_tag :report_reason_l, 'Seems Like Spam' %>
</div>
<div class="form-group">
<%= radio_button_tag :report_reason, 3 %>
<%= label_tag :report_reason_l, 'Underage User' %>
</div>
<div class="form-group">
<%= radio_button_tag :report_reason, 0 %>
<%= label_tag :report_reason_l, 'Other' %>
</div>
<div class="form-group">
<%= text_area_tag 'report_description', nil, placeholder: 'Description...', :autofocus => true, rows: 3, class: 'form-control' %>
</div>
<div class="form-group">
<%= submit_tag "Report", class: "btn btn-primary", id:'submit-report' %>
</div>
<% end %>
<script>
$(function() {
$('#report-form').validate({
rules: {
'report_description' : {
required : true
}
},
messages: {
'report_description' : {
required : "Please mention the reason for reporting this"
}
}
submitHandler: function(form) {
form.submit();
}
});
});
</script>
此处的验证是:如果用户不能将说明留空。
jsfiddle链接是PHP's documentation。
我在哪里验证错误?