From 481f7ee4ba35743170f37aaf48e94791ff5651b1 Mon Sep 17 00:00:00 2001 From: whimlex Date: Fri, 24 Apr 2015 15:08:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=84=8F=E8=A7=81=E5=8F=8D=E9=A6=88=E6=8C=89?= =?UTF-8?q?=E5=9B=9E=E9=80=80=E9=94=AE=E9=87=8D=E6=96=B0=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_feedback.html.erb | 10 +++++----- public/javascripts/feedback.js | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/views/layouts/_base_feedback.html.erb b/app/views/layouts/_base_feedback.html.erb index 8e850b7ed..beaf8d821 100644 --- a/app/views/layouts/_base_feedback.html.erb +++ b/app/views/layouts/_base_feedback.html.erb @@ -141,18 +141,18 @@ function cookieget(n) $(document).ready(function(){ $("#subject").keydown(function(){ var curLength=$("#subject").val().length; - if(curLength>=50){ - var num=$("#subject").val().substr(0,49); + if(curLength>50){ + var num=$("#subject").val().substr(0,50); $("#subject").val(num); } else{ - $("#textCount").text(49-$("#subject").val().length) + $("#textCount").text(50-$("#subject").val().length) } }) $("#subject").keyup(function(){ var curLength=$("#subject").val().length; - if(curLength>=50){ - var num=$("#subject").val().substr(0,49); + if(curLength>50){ + var num=$("#subject").val().substr(0,50); $("#subject").val(num); } else{ diff --git a/public/javascripts/feedback.js b/public/javascripts/feedback.js index 6ba244d6d..1bbab1f45 100644 --- a/public/javascripts/feedback.js +++ b/public/javascripts/feedback.js @@ -116,12 +116,22 @@ $(document).ready(function () { $(document).ready(function(){ $("#subject").keydown(function(){ var curLength=$("#subject").val().length; - if(curLength>=50){ - var num=$("#subject").val().substr(0,49); + if(curLength>50){ + var num=$("#subject").val().substr(0,50); $("#subject").val(num); } else{ - $("#textCount").text(50-$("#subject").val().length); + $("#textCount").text(50-$("#subject").val().length) + } + }) + $("#subject").keyup(function(){ + var curLength=$("#subject").val().length; + if(curLength>50){ + var num=$("#subject").val().substr(0,50); + $("#subject").val(num); + } + else{ + $("#textCount").text(50-$("#subject").val().length) } }) }) \ No newline at end of file