#562课程讨论区回复增加js验证

参赛作品js验证增加左右两端空格去除
This commit is contained in:
sw 2014-10-14 17:09:52 +08:00
parent 64ee96b526
commit 8f402fe0b7
3 changed files with 30 additions and 10 deletions

View File

@ -4,7 +4,7 @@
//验证作品名称
function regexName()
{
var name = $("#softapplication_name").val();
var name = $.trim($("#softapplication_name").val());
if(name.length == 0)
{
$("#spane_name_notice").text("<%= l(:label_no_softapplication_name) %>");
@ -31,7 +31,7 @@
//验证作品简介
function regexDescription()
{
var name = $("#softapplication_description").val();
var name = $.trim($("#softapplication_description").val());
if(name.length ==0)
{
$("#span_sofapplication_description").text("<%= l(:label_no_softapplication_description) %>");
@ -56,7 +56,7 @@
//验证运行平台
function regexWorkdescription()
{
var workDescription = $("#softapplication_android_min_version_available").val();
var workDescription = $.trim($("#softapplication_android_min_version_available").val());
if(workDescription.length ==0)
{
$("#spane_workdescription_notice").text("<%= l(:label_no_softapplication_platform) %>");
@ -80,7 +80,7 @@
//验证开发人员
function regexDevelopers()
{
var workDescription = $("#softapplication_application_developers").val();
var workDescription = $.trim($("#softapplication_application_developers").val());
if(workDescription.length ==0)
{
$("#span_softapplication_application_developers").text("<%= l(:label_no_softapplication_developers) %>");

View File

@ -177,7 +177,8 @@
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
<%= submit_tag l(:button_submit) %>
<%#= submit_tag l(:button_submit) %>
<input type="button" class="enterprise" value="<%=l(:button_submit) %>" onclick="submit_message_replay();" >
<%#= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
<% end %>
<div id="preview" class="wiki"></div>
@ -190,9 +191,27 @@
jQuery(document).ready(function($) {
transpotUrl('#content');
});
// function regexContent()
// {
// var content = trim($("#message_content").val());
// alert(content);
// }
function submit_message_replay()
{
if(regexContent())
{
$("#message-form").submit();
}
}
function regexContent()
{
var content = $.trim($("#message_content").val());
if(content.length ==0)
{
$("#message_content_span").text("<%= l(:label_reply_empty) %>");
$("#message_content_span").css('color','#ff0000');
return false;
}
else
{
$("#message_content_span").text("<%= l(:label_field_correct) %>");
$("#message_content_span").css('color','#008000');
return true;
}
}
</script>

View File

@ -42,6 +42,7 @@
<p>
<%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %>
<%= f.text_area :content, :cols => 80, :rows => 13, :class => 'wiki-edit', :id => 'message_content', :onblur => "regexContent();" %>
<span id="message_content_span"></span>
</p>
<!--[eoform:message]-->