Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to count the words of SharePoint List Item. I have used code, but it shows me only 0 words though I type several words. When I used an alert for holdtextvalue it shows me blank value. Can one tell me what is the problem?

$(document).ready(function()
  {  var holdtextvalue;

     $("#ctl00_m_g_2ff37816_5d5b_42e8_b189_77daaaf2bc56_ff31_ctl00_ctl00_TextField_inplacerte").keyup(function()
     {
        holdtextvalue=$.trim($('txt1').val())
        alert("The value is::"+holdtextvalue);
        var count=holdtextvalue.split(/[\s\.\?]+/).length
         alert(count); 
         return false;  

      });
});
share|improve this question
    
If txt1 is input id, you must use $("#txt1"), your current selector selects all tags with name 'txt1', which is not correct –  Kai Jan 6 '12 at 8:04
    
The question is a little confusing. As I understand the problem is more jQuery/javascript related rather than a SPListItem field. –  Anatoly Mironov Jan 6 '12 at 15:06
add comment

1 Answer

If your textfield looks something like this:

<input name="..." 
    type="text" value="Jordan" 
    id="ctl00_m_g_2ff37816_5d5b_42e8_b189_77daaaf2bc56_ff31_ctl00_ctl00_TextField_inplacerte">

Then you can retrieve the value of this input like Kai mentioned with jQuery id selector:

holdtextvalue=$.trim($('#ctl00_m_g_2ff37816_5d5b_42e8_b189_77daaaf2bc56_ff31_ctl00_ctl00_TextField_inplacerte').val())
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.