From d520f1cdb4d9cc2a261fbf54d2af5170d341f299 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 4 Nov 2014 16:27:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=92=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=A2=9E=E5=8A=A0js=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/edit.html.erb | 22 ++++++++++++++++++++-- app/views/homework_attach/new.html.erb | 24 ++++++++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index 9f81a3d19..5530b8cff 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -14,7 +14,24 @@ } function submit_homework_form() { - $('#edit_homework_attach_<%= @homework.id%>').submit(); + if(regexName()){$('#edit_homework_attach_<%= @homework.id%>').submit();} + } + function regexName() + { + var name = $("#homework_attach_name").val(); + + if(name=="") + { + $("#homework_attach_name_span").text("名称不能为空"); + $("#homework_attach_name_span").css('color','#ff0000'); + return false; + } + else + { + $("#homework_attach_name_span").text("填写正确"); + $("#homework_attach_name_span").css('color','#008000'); + return true; + } } @@ -44,7 +61,8 @@ <%= form_for(@homework) do |f|%>
- <%= f.text_field :name, :required => true, :name => "homework_name", :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称"%> + <%= f.text_field :name, :required => true, :name => "homework_name", :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称", :onblur => "regexName();"%> +