newline using shift + enter in javascript is not behaving as newline in php

596 Views Asked by At

I have a textarea

 <textarea name="a" id="a" onkeyup="gh(event);" cols="30" rows="1"></textarea>

and im using it to transfer text into my server but just like facebook comment box there is no submit button data submits when user presses Enter and when users presses Shift+Enter they are allow to create to new line here is my JS Function

function yh(e) {
  if(e.keyCode)
  {
    unicode = e.keyCode;
  }
  else
  {
    unicode = e.charCode;
  }
  if (e.keyCode == 13 && e.shiftKey)
  {
    return false;
  }
  else if(e.keyCode == 13 )
  {
    //do submit 
  }
}

but when i submit the data and then fetch it then the new line doesnot appearing i have used str_replace("\n","<br/>","$data") and nl2br($data) function of PHP but they are not working can you tell me where is the problem??

0

There are 0 best solutions below