新增和修改作业增加js验证
This commit is contained in:
parent
13c362b08d
commit
d520f1cdb4
|
@ -14,7 +14,24 @@
|
||||||
}
|
}
|
||||||
function submit_homework_form()
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -44,7 +61,8 @@
|
||||||
<%= form_for(@homework) do |f|%>
|
<%= form_for(@homework) do |f|%>
|
||||||
<p>
|
<p>
|
||||||
<label><span class="c_red">*</span> 作品名称 :</label>
|
<label><span class="c_red">*</span> 作品名称 :</label>
|
||||||
<%= 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();"%>
|
||||||
|
<span id="homework_attach_name_span"></span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label> 提交项目
|
<label> 提交项目
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
<%= stylesheet_link_tag 'css', :media => 'all' %>
|
<%= stylesheet_link_tag 'css', :media => 'all' %>
|
||||||
<script type="text/javascript" language="javascript">
|
<script type="text/javascript" language="javascript" xmlns="http://www.w3.org/1999/html">
|
||||||
function submit_homework_form()
|
function regexName()
|
||||||
{
|
{
|
||||||
$('#new_homework_attach').submit();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function submit_homework_form(){if(regexName()){$('#new_homework_attach').submit();}}
|
||||||
</script>
|
</script>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="Newwork">
|
<div class="Newwork">
|
||||||
|
@ -36,7 +51,8 @@
|
||||||
</span>
|
</span>
|
||||||
作品名称 :
|
作品名称 :
|
||||||
</label>
|
</label>
|
||||||
<%= f.text_field "name", :required => true, :size => 60, :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称" %>
|
<%= f.text_field "name", :required => true, :size => 60, :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称", :onblur => "regexName();" %>
|
||||||
|
<span id="homework_attach_name_span"></span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label> 提交项目
|
<label> 提交项目
|
||||||
|
|
Loading…
Reference in New Issue