60 lines
1.8 KiB
Plaintext
60 lines
1.8 KiB
Plaintext
<script type="text/javascript">
|
|
function regexName()
|
|
{
|
|
var name = $("#bid_name").val();
|
|
|
|
if(name=="")
|
|
{
|
|
$("#bid_name_span").text("名称不能为空");
|
|
$("#bid_name_span").css('color','#ff0000');
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
$("#bid_name_span").text("填写正确");
|
|
$("#bid_name_span").css('color','#008000');
|
|
return true;
|
|
}
|
|
}
|
|
function regexDeadLine()
|
|
{
|
|
var deadline = $("#bid_deadline").val();
|
|
var regex = /^\d{4}-\d{2}-\d{2}$/;
|
|
if(deadline=="")
|
|
{
|
|
$("#bid_deadline_span").text("截止日期不能为空");
|
|
$("#bid_deadline_span").css('color','#ff0000');
|
|
return false;
|
|
}
|
|
else if(regex.test(deadline))
|
|
{
|
|
$("#bid_deadline_span").text("填写正确");
|
|
$("#bid_deadline_span").css('color','#008000');
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
$("#bid_deadline_span").text("截止日期格式错误");
|
|
$("#bid_deadline_span").css('color','#ff0000');
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function submitHomework()
|
|
{
|
|
if(regexDeadLine()&®exName())
|
|
{
|
|
$("#new_bid").submit();
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<h3><%=l(:label_course_new_homework)%></h3>
|
|
|
|
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
|
<div class="box tabular">
|
|
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
|
<input type="button" onclick="submitHomework();" value="<%= l(:button_create)%>" class="enterprise">
|
|
<%= javascript_tag "$('#bid_name').focus();" %>
|
|
<% end %>
|
|
</div> |