locked
Rich text column + jQuery keydown event RRS feed

  • Question

  • I can't seem to figure this out; I have a multiple line rich text box column that doesn't recognise when I type text inside the box.  I added this code inside content editor webpart but my keydown event doesn't work, I do not get the alert.  I do get the first alert that shows me the text inside the content editor.  Can anyone help me out with this?  Thank you :) 

    <script type="text/javascript"> $(document).ready(function(){ alert($("textarea[title='My textarea']").val()); $("textarea[title='My textarea']").keydown(function() { alert('Testing...'); }); }); </script>


    Thursday, August 2, 2012 12:00 AM

Answers

  • Hi ,

    When it comes to rich text of multiple line of text field, you need to change the code like this :

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

    <script type="text/javascript">

    $(document).ready(function(){

    var a=$("#ctl00_ctl24_g_033a4807_6c5f_4280_90ae_f6874e868b83_ctl00_ctl05_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_spSave").val();

    alert(a);

    $("#ctl00_ctl24_g_033a4807_6c5f_4280_90ae_f6874e868b83_ctl00_ctl05_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_ TextField_spSave ").keydown(function() {

    alert('Testing...');

    });

    });

    </script>

    The id in the code can be get using IE developer tool.Open the page new form in browser and press F12 to open developer tool. Use the arrow to select the rich text box. Find the id which contains ‘TextField_spSave’ and ‘TextField_spSave’  and replace the id above.

    Thanks,

    Entan Ming


    Entan Ming

    TechNet Community Support

    • Marked as answer by Dranium Tuesday, August 28, 2012 1:09 AM
    Tuesday, August 21, 2012 1:57 AM

All replies

  • Hi,

    Thank you for your question. I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience. Thank you for your understanding and support.

    Thanks,

    Entan Ming


    Entan Ming

    TechNet Community Support

    Friday, August 3, 2012 12:21 PM
  • Thank you for the follow up :)
    Friday, August 3, 2012 2:28 PM
  • Hi ,

    I have a test using your code and find that you have missed one line of code ,you can change the code like this:

    <script type="text/javascript" src="</script">http://code.jquery.com/jquery-latest.js"></script>

    <script type="text/javascript">
    $
    (document).ready(function(){
    alert
    ($("textarea[title='My textarea']").val());
    $
    ("textarea[title='My textarea']").keydown(function() {
    alert
    ('Testing...');
    });
    });
    </script>

    Thanks,

    Entan Ming


    Entan Ming

    TechNet Community Support

    Monday, August 20, 2012 7:15 AM
  • I tried using your code and it doesn't work with rich text, the code only works with plain text.

    Thank you!

    Monday, August 20, 2012 6:55 PM
  • Hi ,

    When it comes to rich text of multiple line of text field, you need to change the code like this :

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

    <script type="text/javascript">

    $(document).ready(function(){

    var a=$("#ctl00_ctl24_g_033a4807_6c5f_4280_90ae_f6874e868b83_ctl00_ctl05_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_spSave").val();

    alert(a);

    $("#ctl00_ctl24_g_033a4807_6c5f_4280_90ae_f6874e868b83_ctl00_ctl05_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_ TextField_spSave ").keydown(function() {

    alert('Testing...');

    });

    });

    </script>

    The id in the code can be get using IE developer tool.Open the page new form in browser and press F12 to open developer tool. Use the arrow to select the rich text box. Find the id which contains ‘TextField_spSave’ and ‘TextField_spSave’  and replace the id above.

    Thanks,

    Entan Ming


    Entan Ming

    TechNet Community Support

    • Marked as answer by Dranium Tuesday, August 28, 2012 1:09 AM
    Tuesday, August 21, 2012 1:57 AM
  • Hi,

       Try this code:

       for refrence richtextbox

         RiechTextbox Keydown event

    Selva.R

    • Proposed as answer by Selva R Thursday, August 23, 2012 10:06 AM
    Thursday, August 23, 2012 10:06 AM