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

参赛作品js验证增加左右两端空格去除
course_group
sw 11 years ago
parent 64ee96b526
commit 8f402fe0b7

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

@ -177,7 +177,8 @@
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= 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} %> <%= 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') %> <%#= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>
@ -190,9 +191,27 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
transpotUrl('#content'); transpotUrl('#content');
}); });
// function regexContent() function submit_message_replay()
// { {
// var content = trim($("#message_content").val()); if(regexContent())
// alert(content); {
// } $("#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> </script>

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

Loading…
Cancel
Save