我希望在我的输入字段填写完毕之前禁用提交按钮。我对rails不是很熟悉,JS和Coffee也不太了解。我一直在尝试运行这个功能,但它没有起作用。我还试图在客户端进行验证,但无法使其工作,代码通过了,但即使所有字段都填写完毕,按钮仍然无法启用。由于某种原因,按钮仍然被禁用。
Html.haml
Html.haml
= simple_form_for @post, html: { multipart: true } do |f|
- if @post.errors.any?
#errors
%h2
= pluralize(@post.errors.count, "error")
prevented this Post from saving
%ul
- @post.errors.full_messages.each do |msg|
%li= msg
.form-group
= f.input :title,:label => "Project Name", input_html: { class: 'form-control' }
.form-group
%label{:for => "Image"} image
%input#image.form-control-file{"aria-describedby" => "fileHelp", :type => "file"}/
.form-group
%label{:for => "url-input"} Project Link
%input#url-input.form-control{:type => "url", :value => "https://"}/
.form-group
%label{:for => "description"} Description
%textarea#description.form-control{:rows => "3"}
%small#descriptionHelp.form-text.text-muted Clear it up please
%button#add.btn.btn-info{:type => "submit", :disabled => "disabled" } submit
Thanks in advance.