i am new to php, javascript and web
I am having a situation => I have to set a value of text field on my client side, i pass value to my javascript function and it sets value as
function editSubService(description){
setVal("sub_service_description", description);
}
and it sets the value right , but if there is new line in the text, it does not set the text field. how can this set that value of text field, its only not working if new line
A <input> element with type="text" will not accept any newline characters. It is, by definition, a single-line field.
Use a <textarea> if you wish to have a multi-line input.
It's specification for type="text", according to MDN:
text: A single-line text field; line-breaks are automatically removed from the input value.
Example:
var area = document.getElementById("sub_service_description");
area.value = "This is some\ntext with a newline character";
console.log(area.value);
<textarea id="sub_service_description"></textarea>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With