0

i create simple function when keyup using javascript like so :

<script>
//when press enter, submit this form, when press shift and enter create new line
$("#text_reply1778").keyup(function(e) {
    var textVal = $(this).val();
    if(e.which == 13 && e.shiftKey) {
        //here create new line
    }
    else if (e.which == 13) {
       e.preventDefault(); 
       var text_input = $("#text_reply1778").val();

       if(text_input != '') { //dont submit if value is empty

           $('#reply1778').ajaxSubmit( {
                target: '#reply_output1778', 
                success: function() { 
                    //do somthing here
                } 
            });  
       }
    }
});
</script>

when i run this using browser Google Chrome Version 26.0.1410.43 my layout will mess-up but this not happen when im using Firefox.

You can try from here (full code) chat1.html , then type any message inside textarea(chat box) then you will see layout will mess-up.

So how to avoid this ? any method that i can use , i try replace keyup with keypress but result still same.

4

0 回答 0