新建pull request的时候JS控制标题不能为空

This commit is contained in:
huang 2016-08-04 14:11:24 +08:00
parent 1f5c4a800f
commit 7084a3fed9
1 changed files with 29 additions and 3 deletions

View File

@ -1,7 +1,7 @@
<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create', :project_id => @project.id), :id => 'pull_request_form', :method => "post", :remote => true) do %>
<div class="new-merge-wrap">
<div class="merge-option-name fl mt8">标题</div><input type="text" name="title" class="merge-title-input fl ml30" />
<!--<p class="fl ml100 fontGrey2 mt5">标题以<span class="c_red">[WIP]</span>或<span class="c_red">WIP</span>开头:以防还在进程中的合并请求在它完成之前被合并</p>-->
<div class="merge-option-name fl mt8">标题</div><input type="text" id="pr_name" name="title" class="merge-title-input fl ml30" />
<p id ="pull_request_title" class="fl ml100 fontGrey2 mt5 c_red" style="display: none">标题不能为空</p>
<div class="cl mb10"></div>
<div class="merge-option-name fl">描述</div><textarea type="text" name="description" class="merge-description-input fl ml30"></textarea>
<!--<p class="fl ml100 f12 mt5"><a href="javascript:void(0);" class="AnnexBtn fl mr10">上传附件</a></p>-->
@ -20,8 +20,34 @@
<div class="cl"></div>
</div>
<div class="new-merge-row b_grey" style="border-top:1px solid #ddd;">
<a href="javascript:void(0);" class="BlueCirBtn fl ml10" onclick="$('#pull_request_form').submit()">提交请求</a>
<a href="javascript:void(0);" class="BlueCirBtn fl ml10" onclick="pull_request_commit()">提交请求</a>
<%= link_to "返回", project_pull_requests_path(:project_id => @project.id), :class => "fr linkGrey2 mt5 mr10" %>
<div class="cl"></div>
</div>
<% end %>
<script>
function regex_pr_name()
{
var name = $.trim($("#pr_name").val());
if(name.length == 0)
{
$("#pull_request_title").show();
return false;
}
else
{
$("#pull_request_title").hide();
return true;
}
}
//提交pull request
function pull_request_commit()
{
if(regex_pr_name())
{
$("#pull_request_form").submit();
}
}
</script>